Android Question TabStripViewPager hide tab page programmatically.

Discussion in 'Android Questions' started by vfafou, Apr 20, 2017.

  1. vfafou

    vfafou Active Member Licensed 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!
     
    Livio F and desof like this.
  2. Erel

    Erel Administrator Staff Member Licensed User

    It requires TabStripViewPager v1.10. You can use this code to add or remove pages:
    Code:
    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(0False)
       
    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
     
    vfafou and Mahares like this.
  3. vfafou

    vfafou Active Member Licensed 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!!!;););)
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice