Android Question Tabstrip: Can You Skip or Hide Tabs When Tabstrip Label is Disabled

Mahares

Expert
Licensed User
Longtime User
I like to delete some tabs and reinstate them when the app calls for it, but since you cannot delete tabs, or hide them, I can disable a tabstrip label. When I swipe a finger to position to a different tab, is there away to skip the disabled label and its page via Reflection or Javaobject and jump to the next enabled page without stopping at the disabled one.
Thank you.
 

Mahares

Expert
Licensed User
Longtime User
ou can use the PageSelected event. Skip to a different page when a "disabled" page is selected.
I am aware of that and did that but here is the dilemma:
I have 7 labels as follows: ENABLED0 DIASBLED1 ENABLED2 DISABLED3 DISABLED4 ENABLED5 ENABLED6

Once I am positioned at ENABLED5, I can swipe right to go to ENABLED6, but if I swipe left to go back to ENABLED2, it gets stuck at ENABLED5 and does not move, unless I physically click ENABLED2.
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. Add two global variables:
B4X:
Private CurrentPage As Int
Private Pages As List

2. Set the enabled and disabled pages:
B4X:
Pages = Array(True, False, False, True, False, False) 'True = Enabled

B4X:
Sub TabStrip1_PageSelected (Position As Int)
   Dim FixedPosition As Int = -1
   If Pages.Get(Position) = False Then
     Dim direction As Int = Position - CurrentPage
     Dim i As Int = Position + direction
     Do While i >= 0 And i < Pages.Size
       If Pages.Get(i) = True Then
         FixedPosition = i
         Exit
       End If
       i = i + direction
     Loop
     If FixedPosition = -1 Then FixedPosition = CurrentPage
   Else
     FixedPosition = Position
   End If
   CurrentPage = FixedPosition
   TabStrip1.ScrollTo(FixedPosition, True)
End Sub
 
Upvote 0
Top