Android Question TabStripViewPager hide tab page programmatically.

vfafou

Well-Known Member
Licensed User
Longtime User
Hello!
I'm about to use TabStripViewPager for a new project that requires eventually hiding of a specific tab page.
I didn't find how could I do that with JavaObject.
If it is not implemented, I would like to have it because it's a perfect tab page lib.
Thank you in advance!
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
It requires TabStripViewPager v1.10. You can use this code to add or remove pages:
B4X:
Sub InsertPage (ts As TabStrip, Index As Int, Page As Panel, Title As String)
   Dim jo As JavaObject = ts
   jo.GetFieldJO("pages").RunMethod("add", Array(Index, Page))
   jo.GetFieldJO("titles").RunMethod("add", Array(Index, Title))
   RefreshTabStrip(ts)
End Sub

'Return the removed page
Sub RemovePage (ts As TabStrip, Index As Int) As Panel
   If ts.CurrentPage >= Index Then ts.ScrollTo(0, False)
   Dim jo As JavaObject = ts
   Dim p As Panel = jo.GetFieldJO("pages").RunMethod("remove", Array(Index))
   jo.GetFieldJO("titles").RunMethod("remove", Array(Index))
   RefreshTabStrip (ts)
   Return p
End Sub

Sub RefreshTabStrip(ts As TabStrip)
   Dim jo As JavaObject = ts
   jo.RunMethod("resetAdapter", Null)
   jo.GetFieldJO("vp").RunMethodJO("getAdapter", Null).RunMethod("notifyDataSetChanged", Null)
   jo.GetFieldJO("tabStrip").RunMethod("notifyDataSetChanged", Null)
End Sub
 
Upvote 0

vfafou

Well-Known Member
Licensed User
Longtime User
Thank you Erel!
It seems that you've done the update of the lib just for me!!!
You're very kind and you just take care of your ecosystem persons!
Thank you, thank you, thank you!!!;););)
 
Upvote 0
Top