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:
Code: Copy
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
...
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
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
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
It happens because the TabStrip is inside the CustomListView. The solution is to remove the panels click recognizer:
Code: Copy
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
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: Copy
Sub TabStrip1_PageSelected (Position As Int)
    Log("Current page: " & Position)
End Sub

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

Similar Threads

  • Question Question
iOS Question TabStrip question
Replies
5
Views
4K
  • Question Question
iOS Question TabStrip error
Replies
13
Views
6K
  • Locked
  • Article Article
B4i Library TabStrip
Replies
26
Views
22K
Back
Top