B4A Library CarouselView - a Carousel for displaying images

A wrapper for this Github project. posting the following:
1. B4A library files - copy them to your additional library folder
2. B4A project to demonstrate the library

You will need to have android-support-v4.jar in your additional library folder. You can download it from here:
https://www.dropbox.com/s/qmggn0wm5a6bqa9/android-support-v4.jar?dl=0

It can used in Auto or Manual mode to display the images that were added to the carousel. It has a nice page indicator that can be customised (outline color, circle size, fill color, etc)

1.png


2.png


Sample Code:

B4X:
#Region  Project Attributes
    #ApplicationLabel: CarouselView
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#AdditionalRes: ..\Resources

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private cv1 As CarouselView
 
    Dim bm As Bitmap
    Dim blist As List                               'images to be passed to the library via this list
 
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
     Activity.LoadLayout("main")
 
     blist.Initialize                                     'initialize an empty list
 
     bm.Initialize(File.DirAssets, "image_1.jpg")
     blist.Add(bm)                                        'add the image to the list
     bm.Initialize(File.DirAssets, "image_2.jpg")
     blist.Add(bm)
     bm.Initialize(File.DirAssets, "image_3.jpg")
     blist.Add(bm)
     bm.Initialize(File.DirAssets, "image_4.jpg")
     blist.Add(bm)
     bm.Initialize(File.DirAssets, "image_5.jpg")
     blist.Add(bm)               
 
     cv1.ImageBitmaps = blist                              'pass the list with images to the library

     cv1.Radius = 10                                       'the radius of the indicator circles
     cv1.StrokeColor = Colors.Magenta                      'the outline color of the circles
     cv1.StrokeWidth = 5                                   'the width of the outline circles
     cv1.FillColor = Colors.White                          'the color to fill the circles with - active page/image
     cv1.AutoPlay = True                                   'play automatically?
     cv1.CurrentItem = 0                                   'set the indeks of where to initially start from: 0 to (number of image - 1)
     cv1.DisableAutoPlayOnUserInteraction = True           'stop auto play if image is touched during autoplay
     cv1.Orientation = cv1.ORIENTATION_HORIZONTAL          'can also be ORIENTATION_VERTICAL in which case it will be position to the left of the CarouselView
     cv1.PageCount = blist.Size                            'the number of pages/images to display
     cv1.PageColor = Colors.Transparent                       'the color in the centre of the indicator circles for "not active" pages
     cv1.SlideInterval = 1000                              'the slide interval in milli seconds
 
     cv1.playCarousel                                      'kickstart the carousel into action
 
     ' there is also cv1.pauseCarousel that can be used to pause the carousel

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Library:

CarouselView
Author:
Github: Sayyam Mehmood, Wrapped by: Johan Schoeman
Version: 1
  • CarouselView
    Fields:
    • ORIENTATION_HORIZONTAL As Int
    • ORIENTATION_VERTICAL As Int
    • ba As BA
    Methods:
    • BringToFront
    • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
    • Initialize (EventName As String)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    • pauseCarousel
      Stops auto scrolling.
    • playCarousel
      Starts auto scrolling if
    Properties:
    • AutoPlay As Boolean [write only]
      Set interval for one slide in milliseconds.
    • Background As Drawable
    • Color As Int [write only]
    • CurrentItem As Int [write only]
    • DisableAutoPlayOnUserInteraction As Boolean [write only]
    • Enabled As Boolean
    • FillColor As Int [write only]
    • Height As Int
    • ImageBitmaps As List [write only]
    • Left As Int
    • Orientation As Int [write only]
    • PageColor As Int [write only]
    • PageCount As Int [write only]
    • Parent As Object [read only]
    • Radius As Float [write only]
    • SlideInterval As Int [write only]
      Set interval for one slide in milliseconds.
    • Snap As Boolean [write only]
    • StrokeColor As Int [write only]
    • StrokeWidth As Float [write only]
    • Tag As Object
    • Top As Int
    • Visible As Boolean
    • Width As Int
 

Attachments

  • CarouselViewLibFiles.zip
    27 KB · Views: 1,020
  • b4aCarouselView.zip
    307.7 KB · Views: 908
  • b4aCarouselView-AndroidX.zip
    307.7 KB · Views: 746
Last edited by a moderator:

Seneca

Active Member
Licensed User
Hi,

Is it possible to change the distance between the circles and the bottom edge?

Thank for the lib.

Regards.
 
Last edited:

Johan Schoeman

Expert
Licensed User
Longtime User
I think I've found the solution. I need to modify the Objects/res/layout/view_carousel.xml file.

It is right?
I guess you will have to play around with the code in view_carousel.xml to change the position
B4X:
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
       xmlns:app="http://schemas.android.com/apk/res-auto">

    <android.support.v4.view.ViewPager
        android:id="@+id/containerViewPager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

    <main.java.com.synnapps.carouselview.CirclePageIndicator
        android:id="@+id/indicator"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="25dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:padding="10dip"
        app:centered="true"/>

</merge>

Remember to disable the read only property of view_caroucel.xml before changing the code and once changed and saved to enable the read only property again
 

Johan Schoeman

Expert
Licensed User
Longtime User
It is possible for smooth transitions between images in AutoPlay @Johan Schoeman ?

Thank you for your work! Awesome library!!!
Explain what you mean by smooth transitions? Not sure what it is that you would like to see happening.
 

Johan Schoeman

Expert
Licensed User
Longtime User
It is possible for smooth transitions between images in AutoPlay @Johan Schoeman ?

Thank you for your work! Awesome library!!!
Here is an update based on the latest update of the Github project (see post #1 of this thread for the link). It allows you to set the image display time as well as the image transition time. It also adds the following:
1. Positioning of the page indicator (gravity - see the various options available)
2. Set the page indicator to snap mode (watch the page indicator when choosing true / false)
3. Set the page transformation (5 options available)

1.gif


Sample Code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: CarouselViewNew
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
#End Region


#Region  Activity Attributes
    #FullScreen: True
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private cv1 As CarouselViewNew

    Dim bm As Bitmap
    Dim blist As List                               'images to be passed to the library via this list

    Private l1 As Label

    Dim fruit(5) As String
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
     Activity.LoadLayout("main")
 

     blist.Initialize                                     'initialize an empty list
  
    'Dim in As InputStream
    'in = File.OpenInput(File.DirRootExternal, "/pictures/image_1.jpg")
    'bm.Initialize2(in)                                           'Export the generated bitmap to a PNG and save in in the pictures folder                                                                  'Make sure nothing is stuck that should have been written
    'in.Close      
    'blist.Add(bm)
    '
    'Dim in As InputStream
    'in = File.OpenInput(File.DirRootExternal, "/pictures/image_2.jpg")
    'bm.Initialize2(in)                                           'Export the generated bitmap to a PNG and save in in the pictures folder                                                                  'Make sure nothing is stuck that should have been written
    'in.Close      
    'blist.Add(bm)
    '
    'Dim in As InputStream
    'in = File.OpenInput(File.DirRootExternal, "/pictures/image_3.jpg")
    'bm.Initialize2(in)                                           'Export the generated bitmap to a PNG and save in in the pictures folder                                                                  'Make sure nothing is stuck that should have been written
    'in.Close      
    'blist.Add(bm)
    '
    'Dim in As InputStream
    'in = File.OpenInput(File.DirRootExternal, "/pictures/image_4.jpg")
    'bm.Initialize2(in)                                           'Export the generated bitmap to a PNG and save in in the pictures folder                                                                  'Make sure nothing is stuck that should have been written
    'in.Close      
    'blist.Add(bm)
    '
    'Dim in As InputStream
    'in = File.OpenInput(File.DirRootExternal, "/pictures/image_5.jpg")
    'bm.Initialize2(in)                                           'Export the generated bitmap to a PNG and save in in the pictures folder                                                                  'Make sure nothing is stuck that should have been written
    'in.Close      
    'blist.Add(bm)
 
     bm.Initialize(File.DirAssets, "image_1.jpg")
     blist.Add(bm)                                        'add the image to the list
     bm.Initialize(File.DirAssets, "image_2.jpg")
     blist.Add(bm)
     bm.Initialize(File.DirAssets, "image_3.jpg")
     blist.Add(bm)
     bm.Initialize(File.DirAssets, "image_4.jpg")
     blist.Add(bm)
     bm.Initialize(File.DirAssets, "image_5.jpg")
     blist.Add(bm) 
 
     fruit = Array As String("Orange", "Grapes", "Strawberry", "Cherry", "Apricot")           
 
     cv1.ImageBitmaps = blist                              'pass the list with images to the library

     cv1.Radius = 10                                       'the radius of the indicator circles
     cv1.StrokeColor = Colors.Magenta                      'the outline color of the circles
     cv1.StrokeWidth = 5                                   'the width of the outline circles
     cv1.FillColor = Colors.White                          'the color to fill the circles with - active page/image                               'play automatically?
     cv1.DisableAutoPlayOnUserInteraction = True           'stop auto play if image is touched during autoplay
     cv1.Orientation = cv1.ORIENTATION_HORIZONTAL          'can also be ORIENTATION_VERTICAL in which case it will be position to the left of the CarouselView
     cv1.PageCount = blist.Size                            'the number of pages/images to display
     cv1.PageColor = Colors.Transparent                       'the color in the centre of the indicator circles for "not active" pages
     cv1.SlideInterval = 3000                              'the slide interval in milli seconds
     cv1.PageTransformInterval = 1500
     cv1.AnimateOnBoundary = True
     cv1.IndicatorGravity = cv1.GRAVITY_RIGHT_TOP          'see other gravity options available
     cv1.PageColor = Colors.white
     cv1.PageTransformer = cv1.TRANSFORMER_SLIDE_OVER      'see other transformer options
     cv1.Snap = False                                      'watch the behaviour of the page indicator....
 
     cv1.playCarousel                                      'kickstart the carousel into action
 
     'there is also cv1.pauseCarousel that can be used to pause the carousel

End Sub

Sub Activity_Resume

     Dim curitem As Int = 0
     cv1.CurrentItem = curitem                             'set the indeks of where to initially start from: 0 to (number of image - 1)
     l1.Text = fruit(curitem)

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub cv1_picture_changed (pos As Int)

    l1.Text = fruit(pos)

End Sub

Sub cv1_scroll_stopped

    Log("auto scroll stopped due to user drag")

End Sub

Sub cv1_picture_touched(position As Int)

    Log("Picture Touched = " & fruit(position))

End Sub

Sub cv1_picture_long_touched(position As Int)

    Log("Picture Long Touched = " & fruit(position))

End Sub
 

Attachments

  • CarouselViewNewLibFiles.zip
    32.4 KB · Views: 451
  • b4aCarouselViewNew.zip
    309.1 KB · Views: 458
Last edited:

Alpandino

Member
Licensed User
Hi,
with this library version it seems that is not possible to change the distance between the circles and the bottom edge (same question posted by Seneca). With previous version this was possible changing the xml file.
How can we achieve this now?

Thank you
 

Johan Schoeman

Expert
Licensed User
Longtime User
Hi,
with this library version it seems that is not possible to change the distance between the circles and the bottom edge (same question posted by Seneca). With previous version this was possible changing the xml file.
How can we achieve this now?

Thank you
You can set the vertical "margin" by editing this line....
<dimen name="default_indicator_margin_vertical">100dp</dimen>

....in Objects/res/values/defaults.xml of the B4A project.
 

Alpandino

Member
Licensed User
You can set the vertical "margin" by editing this line....
<dimen name="default_indicator_margin_vertical">100dp</dimen>

....in Objects/res/values/defaults.xml of the B4A project.
Hi,
I inserted the line
<dimen name="default_indicator_margin_vertical">1p</dimen>
but nothing is changed.
I inserted also the line
<dimen name="default_circle_indicator_margin_vertical">1dp</dimen>
but nothing is changed again.

I'm doing some mistake?
 

Alpandino

Member
Licensed User
Hi,
I inserted the line
<dimen name="default_indicator_margin_vertical">1p</dimen>
but nothing is changed.
I inserted also the line
<dimen name="default_circle_indicator_margin_vertical">1dp</dimen>
but nothing is changed again.

I'm doing some mistake?

Sorry, I'm a stupid person.
I was using the old library.
Now I'm using the new library and it works!

Thank you!
 

josejad

Expert
Licensed User
Longtime User
Hi:

I've tested the example and it works perfectly, but I'm trying to use it in my project, and I get an error.
Testing a lot of things, I just try to load the layout with the CarrouselView and I get the error.
I mean, I have a xCustomScrollView, and when I click in one of the items, I call Activity.LoadLayout("carousel"). This layout have just the CarouselViewNew, and I get and error in that line:

B4X:
Error occurred on line: 188 (Checklist)
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
    at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:342)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1051)
    at anywheresoftware.b4a.keywords.Common.CallSubNew3(Common.java:1001)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:342)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
    at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:259)
    at b4a.example.customlistview$ResumableSub_PanelClickHandler.resume(customlistview.java:964)
    at b4a.example.customlistview._panelclickhandler(customlistview.java:948)
    at b4a.example.customlistview._panel_click(customlistview.java:941)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:342)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:5637)
    at android.view.View$PerformClick.run(View.java:22433)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6119)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
    ... 36 more
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
    at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:190)
    at android.content.res.Resources.loadXmlResourceParser(Resources.java:2101)
    at android.content.res.Resources.getLayout(Resources.java:1115)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:424)
    at com.synnapps.carouselview.CarouselView.initView(CarouselView.java:88)
    at com.synnapps.carouselview.CarouselView.<init>(CarouselView.java:70)
    at carouselviewnewwrapper.carouselviewnewWrapper._initialize(carouselviewnewWrapper.java:108)
    ... 39 more
** Service (starter) Destroy **
** Activity (checklist) Pause, UserClosed = true **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
[[FechaChkl=22/11/2017, IsInitialized=true, Site=2900040
, Tecnologia=U09, TipoInstalacion=Compacto], [FechaChkl=22/11/2017, IsInitialized=true, Site=1100040
, Tecnologia=U21, TipoInstalacion=Distribuido], [FechaChkl=22/11/2017, IsInitialized=true, Site=2901241
, Tecnologia=L08, TipoInstalacion=Distribuido], [FechaChkl=22/11/2017, IsInitialized=true, Site=2300856
Distribuido
, Tecnologia=L08, TipoInstalacion=Distribuido], [FechaChkl=22/11/2017, IsInitialized=true, Site=2309956
, Tecnologia=U21, TipoInstalacion=Distribuido]]
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
Sleep not resumed (context is paused): anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub
** Activity (checklist) Create, isFirst = true **
** Activity (checklist) Resume **
Error occurred on line: 188 (Checklist)
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
    at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:342)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1051)
    at anywheresoftware.b4a.keywords.Common.CallSubNew3(Common.java:1001)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:342)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
    at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:259)
    at b4a.example.customlistview$ResumableSub_PanelClickHandler.resume(customlistview.java:998)
    at b4a.example.customlistview._panelclickhandler(customlistview.java:982)
    at b4a.example.customlistview._panel_click(customlistview.java:975)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:342)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:5637)
    at android.view.View$PerformClick.run(View.java:22433)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6119)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
    ... 36 more
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
    at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:190)
    at android.content.res.Resources.loadXmlResourceParser(Resources.java:2101)
    at android.content.res.Resources.getLayout(Resources.java:1115)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:424)
    at com.synnapps.carouselview.CarouselView.initView(CarouselView.java:88)
    at com.synnapps.carouselview.CarouselView.<init>(CarouselView.java:70)
    at carouselviewnewwrapper.carouselviewnewWrapper._initialize(carouselviewnewWrapper.java:108)
    ... 39 more
 

Johan Schoeman

Expert
Licensed User
Longtime User
Hi:

I've tested the example and it works perfectly, but I'm trying to use it in my project, and I get an error.
Testing a lot of things, I just try to load the layout with the CarrouselView and I get the error.
I mean, I have a xCustomScrollView, and when I click in one of the items, I call Activity.LoadLayout("carousel"). This layout have just the CarouselViewNew, and I get and error in that line:

B4X:
Error occurred on line: 188 (Checklist)
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
    at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:342)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1051)
    at anywheresoftware.b4a.keywords.Common.CallSubNew3(Common.java:1001)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:342)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
    at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:259)
    at b4a.example.customlistview$ResumableSub_PanelClickHandler.resume(customlistview.java:964)
    at b4a.example.customlistview._panelclickhandler(customlistview.java:948)
    at b4a.example.customlistview._panel_click(customlistview.java:941)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:342)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:5637)
    at android.view.View$PerformClick.run(View.java:22433)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6119)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
    ... 36 more
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
    at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:190)
    at android.content.res.Resources.loadXmlResourceParser(Resources.java:2101)
    at android.content.res.Resources.getLayout(Resources.java:1115)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:424)
    at com.synnapps.carouselview.CarouselView.initView(CarouselView.java:88)
    at com.synnapps.carouselview.CarouselView.<init>(CarouselView.java:70)
    at carouselviewnewwrapper.carouselviewnewWrapper._initialize(carouselviewnewWrapper.java:108)
    ... 39 more
** Service (starter) Destroy **
** Activity (checklist) Pause, UserClosed = true **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
[[FechaChkl=22/11/2017, IsInitialized=true, Site=2900040
, Tecnologia=U09, TipoInstalacion=Compacto], [FechaChkl=22/11/2017, IsInitialized=true, Site=1100040
, Tecnologia=U21, TipoInstalacion=Distribuido], [FechaChkl=22/11/2017, IsInitialized=true, Site=2901241
, Tecnologia=L08, TipoInstalacion=Distribuido], [FechaChkl=22/11/2017, IsInitialized=true, Site=2300856
Distribuido
, Tecnologia=L08, TipoInstalacion=Distribuido], [FechaChkl=22/11/2017, IsInitialized=true, Site=2309956
, Tecnologia=U21, TipoInstalacion=Distribuido]]
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
Sleep not resumed (context is paused): anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub
** Activity (checklist) Create, isFirst = true **
** Activity (checklist) Resume **
Error occurred on line: 188 (Checklist)
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
    at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:342)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1051)
    at anywheresoftware.b4a.keywords.Common.CallSubNew3(Common.java:1001)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:342)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
    at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:259)
    at b4a.example.customlistview$ResumableSub_PanelClickHandler.resume(customlistview.java:998)
    at b4a.example.customlistview._panelclickhandler(customlistview.java:982)
    at b4a.example.customlistview._panel_click(customlistview.java:975)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:342)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:5637)
    at android.view.View$PerformClick.run(View.java:22433)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6119)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
    ... 36 more
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
    at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:190)
    at android.content.res.Resources.loadXmlResourceParser(Resources.java:2101)
    at android.content.res.Resources.getLayout(Resources.java:1115)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:424)
    at com.synnapps.carouselview.CarouselView.initView(CarouselView.java:88)
    at com.synnapps.carouselview.CarouselView.<init>(CarouselView.java:70)
    at carouselviewnewwrapper.carouselviewnewWrapper._initialize(carouselviewnewWrapper.java:108)
    ... 39 more
You are missing the resources in your project. See the files in the /Objects/res folder(s) of the sample project and make sure you have them in your project and that the property of files are set to READ ONLY....
 

josejad

Expert
Licensed User
Longtime User
Thanks¡¡ Now it's working
 

Anser

Well-Known Member
Licensed User
Longtime User
This beautiful library is failing in AndroidX and B4A 9.30. Is there any way to make this work with the new AnfroidX requirement ?

I get the following runtime error

android.view.InflateException: Binary XML file line #5: Binary XML file line #5: Error inflating class android.support.v4.view.ViewPager
Caused by: android.view.InflateException: Binary XML file line #5: Error inflating class android.support.v4.view.ViewPager
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.view.ViewPager" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.myappname.publicapp-CF8fRyFFHO7HG_Lr8SyJPw==/base.apk"],nativeLibraryDirectories=[/data/app/com.myappname.publicapp-CF8fRyFFHO7HG_Lr8SyJPw==/lib/arm64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:829)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:769)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:902)
at android.view.LayoutInflater.inflate(LayoutInflater.java:528)
at android.view.LayoutInflater.inflate(LayoutInflater.java:461)
at main.java.com.synnapps.carouselview.CarouselView.initView(CarouselView.java:79)
at main.java.com.synnapps.carouselview.CarouselView.<init>(CarouselView.java:61)
at carouselviewwrapper.carouselViewWrapper._initialize(carouselViewWrapper.java:105)
at carouselviewwrapper.carouselViewWrapper.Initialize(carouselViewWrapper.java:98)
at com.myappname.publicapp.myactivity._buildclv(myactivity.java:578)
at com.myappname.publicapp.myactivity._reqmanager_result(myactivity.java:1308)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.keywords.Common$11.run(Common.java:1179)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7263)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
** Activity (myactivity) Pause, UserClosed = false **
 

Anser

Well-Known Member
Licensed User
Longtime User
Based on the error message the library wasn't jetified.
It is jetified and I have the following files in my external libs folder
CarouselView.androidx.jar
CarouselView.jar
CarouselView.xml
 

Anser

Well-Known Member
Licensed User
Longtime User
Any help ?
Will any change in the XML file of this library makes this library ready/compatible for AndroidX ?

At the bottom end of the CarousalView.xml there is a following entry
<dependsOn>android-support-v4</dependsOn>
 
Top