With reference to this post:
https://www.b4x.com/android/forum/threads/tabstrip-access-events.80845/#post-512196
I have tried to get the sample code working on the demo TabStripViewPager app.
I am finding that I am getting a whole lot of Args, but:
1. One movement of the swipe is generating a large number of events. Screenshot below:
2. I don't know which of these events gives me the ID for the current Activated Tab.
Clearly there is something missing in my understanding of the code.
Can you please advise how I can get the ID?
I would envision an algorithm like this:
https://www.b4x.com/android/forum/threads/tabstrip-access-events.80845/#post-512196
I have tried to get the sample code working on the demo TabStripViewPager app.
B4X:
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Main")
TabStrip1.LoadLayout("Page1", "")
TabStrip1.LoadLayout("Page2", "")
TabStrip1.LoadLayout("Page3", "")
For i = 1 To 100
Page3ListView1.AddSingleLine($"Item ${i}"$)
Next
Dim jo As JavaObject = TabStrip1
Dim event As Object = jo.CreateEventFromUI("android.support.v4.view.ViewPager.OnPageChangeListener", "PageChangeListener", Null)
jo.GetFieldJO("tabStrip").RunMethod("setOnPageChangeListener", Array(event))
End Sub
Sub TabStrip1_PageSelected (Position As Int)
Log($"Current page: ${Position}"$)
End Sub
Sub PageChangeListener_Event (MethodName As String, Args() As Object) As Object
Log("Method: " & MethodName)
Dim ArgsList As List = Args
Log("Args: " & ArgsList)
Return Null
End Sub
I am finding that I am getting a whole lot of Args, but:
1. One movement of the swipe is generating a large number of events. Screenshot below:
2. I don't know which of these events gives me the ID for the current Activated Tab.
Clearly there is something missing in my understanding of the code.
Can you please advise how I can get the ID?
I would envision an algorithm like this:
B4X:
PseudoCode:
1. User Swipes to New Tab
2. PageChangeListener Event Fires
3. PageChangeListener Event Handler provides:
- PageID that was swipped from
- PageID that was sipped to
4. Handle actions accordingly