B4A Library [B4X] [XUI] AS View Pager based on xCustomListView

Alexander Stolte

Well-Known Member
Licensed User
Hey,
thanks to @KZero for his good zPager class, i was able to extract a few things from it to make this cross platform view.

I spend a lot of time in creating views, some views i need by my self, but some views not and to create a high quality view cost a lot of time. If you want to support me, then you can do it here by Paypal. :)

This library is compatible and tested with B4A,B4I and B4J!
If you have bugs or a wish then tell me it in the comments.

On B4J use the LEFT and RIGHT keys on your keyboard to change the page.
On B4I you need the GestureRecognizer class.
B4j: jXUI,JavaObject,xCustomListView,jReflection
B4a: XUi,Reflection,xCustomListView
B4i: iXUI,xCustomListView
Features
  • cross-platform compatible
  • based on a cross-platform ListView
  • add and remove pages
  • scroll to pages
  • a good swipe feeling
20-04-22-20-36-012.gif
ASViewPager
Author: Alexander Stolte
Version: 1.04

  • ASViewPager
    • Events:
      • PageChanged (Index As Int)
      • ReachEnd
      • ScrollChanged (Offset As Int)
    • Functions:
      • AddPage (xpnl_layout As B4XView, value As Object) As String
      • Class_Globals As String
      • DesignerCreateView (Base As Object, Lbl As Label, Props As Map) As String
        Base type must be Object
      • getCurrentIndex As Int
      • getCustomListView As b4a.example3.customlistview
      • getSize As Int
      • Initialize (Callback As Object, EventName As String) As String
      • IsInitialized As Boolean
        Tests whether the object has been initialized.
      • NextPage As String
      • PreviousPage As String
      • RemovePage (index As Int) As String
      • setCurrentIndex (index As Int) As String
    • Properties:
      • CurrentIndex As Int
      • CustomListView As b4a.example3.customlistview [read only]
      • Size As Int [read only]
Changelog
  • 1.00
    • Release
  • 1.01
    • Base_Resize is now public
    • NextPage and PreviousPage Bug Fix
    • setCurrentIndex Bug Fix
    • PageChangeEvent Bug Fix
  • 1.02
    • B4I Bug Fixes
    • NextPage and PreviousPage Bug Fix
  • 1.03
    • Resize BugFix
  • 1.04
    • B4I Page-Height BugFix
    • B4I Page-Swipe BugFix
  • 1.05
    • BugFix
Have Fun :)
 

Attachments

Last edited:

KZero

Active Member
Licensed User
Nice work 🙌

working well except an error when it reaches the end
java.lang.IndexOutOfBoundsException: Invalid index 101, size is 101
 

nelson costa

Member
Licensed User
Error when version target to 29 (Android 10)

thanks.
................................
Error occurred on line: 78 (ASViewPager)
java.lang.NoSuchFieldException: No field mColorStateList in class Landroid/graphics/drawable/GradientDrawable$GradientState; (declaration of 'android.graphics.drawable.GradientDrawable$GradientState' appears in /system/framework/framework.jar)
at java.lang.Class.getDeclaredField(Native Method)
at anywheresoftware.b4a.objects.B4XViewWrapper.getColor(B4XViewWrapper.java:388)
at b4a.example3.customlistview._designercreateview(customlistview.java:305)
at com.as.viewpager.asviewpager._ini_xclv(asviewpager.java:306)
at com.as.viewpager.asviewpager._designercreateview(asviewpager.java:252)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:61)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
at com.as.viewpager.main._activity_create(main.java:391)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at com.as.viewpager.main.afterFirstLayout(main.java:104)
at com.as.viewpager.main.access$000(main.java:17)
at com.as.viewpager.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7860)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)
** Activity (main) Resume **
 
Top