iOS Question [Solved] Clicking on the TabStrip header to jump to Page

Solution
It happens because the TabStrip is inside the CustomListView. The solution is to remove the panels click recognizer:
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    TabPagesAll.Initialize
    For i = 0 To 4
        Dim pnl As B4XView = CreateListItem(CustomListView1.AsView.Width, 400dip)
        CustomListView1.Add(pnl, i)
        RemoveClickRecognizer(pnl)
    Next
End Sub

#if B4i
Private Sub RemoveClickRecognizer (pnl As B4XView)
    Dim no As NativeObject = pnl.Parent
    Dim recs As List = no.GetField("gestureRecognizers")
    For Each rec As Object In recs
        no.RunMethod("removeGestureRecognizer:", Array(rec))
    Next
End Sub
#End If
...

aeric

Expert
Licensed User
Longtime User
In B4A, TabHost behaves normally by clicking on the header but in B4i iTabstrip, I can only swipe on the page.
Not sure is it because I put it inside CustomListview.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Here is my example project.
 

Attachments

  • CustomListViewAndTabStrip.zip
    173.2 KB · Views: 234
Upvote 0

mcqueccu

Expert
Licensed User
Longtime User
Why aren't you using Views from @Alexander Stolte?

They are cross platform, have lots of features, easily customizable and more.

You can combine the AsViewpager with As_tabmenuadvanced to achieve this beautifully.


or


or

 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Why aren't you using Views from @Alexander Stolte?

They are cross platform, have lots of features, easily customizable and more.

You can combine the AsViewpager with As_tabmenuadvanced to achieve this beautifully.


or


or

Because I haven't tested it.
Have you tested it worked on CustomListview?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
It happens because the TabStrip is inside the CustomListView. The solution is to remove the panels click recognizer:
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    TabPagesAll.Initialize
    For i = 0 To 4
        Dim pnl As B4XView = CreateListItem(CustomListView1.AsView.Width, 400dip)
        CustomListView1.Add(pnl, i)
        RemoveClickRecognizer(pnl)
    Next
End Sub

#if B4i
Private Sub RemoveClickRecognizer (pnl As B4XView)
    Dim no As NativeObject = pnl.Parent
    Dim recs As List = no.GetField("gestureRecognizers")
    For Each rec As Object In recs
        no.RunMethod("removeGestureRecognizer:", Array(rec))
    Next
End Sub
#End If

 
Upvote 0
Solution

aeric

Expert
Licensed User
Longtime User
Not a big issue, just want to report a strange behavior.
If jump from tab A to tab B (where B - A > 1), it logs 2 times. ---> It logs Tab n-1 and Tab n.
If jump from tab A to tab B (where B - A = 1), it only logs 1 time.

B4X:
Sub TabStrip1_PageSelected (Position As Int)
    Log("Current page: " & Position)
End Sub

E.g Jumping from Page 1 to Page 5
B4X:
Current page: 3
Current page: 4
 
Upvote 0

Similar Threads

Top