B4A Class [B4X] [XUI] AS TabStrip (ASViewPager + ASTabMenu)

Hello,
this is a helper class to make it easier to create a tabstrip from the ASViewPager and ASTabMenu.

Important
You need ASTabMenu V1.13+

I spend a lot of time in creating views, some views i need by my self, but some views not and to create a high quality view cost a lot of time. If you want to support me, then you can do it here by Paypal. :)

Features
Result:
20-04-23-12-12-422.gif


Tutorial:
  • Step 1
    • Add the ASTabMenu on top
    • Add the ASViewPager under the ASTabMenu
    • look on the image below
    • 1587638329972.png
  • Step 2
    • Initialize the ASTabStrip class
      • ASTabStrip1.Initialize(ASTabMenu1,ASViewPager1)
  • Step 3
    • Add Pages
      • ASTabStrip add pages:
        For i = 0 To 5
        Dim tmp_xpnl As B4XView = xui.CreatePanel("")
        tmp_xpnl.Color = xui.Color_ARGB(255,Rnd(1,255),Rnd(1,255),Rnd(1,255))
        tmp_xpnl.SetLayoutAnimated(0,0,0,ASViewPager1.CustomListView.GetBase.Width,ASViewPager1.CustomListView.GetBase.Height)
        ASTabStrip1.AddPage(xui.Color_ARGB(255,39, 174, 97),"Tab " & i,ASTabMenu1.FontToBitmap(Chr(0xF015),False,30,xui.Color_White),"",tmp_xpnl,"")
            Next
  • Step 4
    • Add the ASViewPager PageChanged event
    • Add the ASTabMenu TabClick event
    • B4X:
      Sub ASViewPager1_PageChanged(Index As Int)
      ASTabStrip1.ViewPager_PageChanged(Index)
      End Sub
      
      Sub ASTabMenu1_TabClick(index As Int)
      ASTabStrip1.TabMenu_TabClick(index)
      End Sub
  • Done
ASTabStrip
Author: Alexander Stolte
Version: 1.00

  • ASTabStrip
    • Functions:
      • AddPage (tab_background_color As Int, tab_text As String, tab_icon As B4XBitmap, tab_tag As Object, pager_layout As B4XView, pager_value As Object) As String
      • Initialize (TabMenu As com.as.tabstrip.astabmenu, ViewPager As com.as.tabstrip.asviewpager) As String
        Initializes the object. You can add parameters to this method if needed.
      • IsInitialized As Boolean
        Tests whether the object has been initialized.
      • RemovePage (index As Int) As String
      • TabMenu_TabClick (index As Int) As String
      • ViewPager_PageChanged (index As Int) As String
Changelog
  • V1.0
    • Release
Have Fun :)
 

Attachments

  • B4A Example.zip
    4 KB · Views: 530
  • ASTabStrip.b4xlib
    916 bytes · Views: 490
  • ASTabStrip.bas
    1.1 KB · Views: 422
Last edited:

shrs

New Member
ASTabStrip
Author: Alexander Stolte
Version: 1.00

  • ASTabStrip
    • Functions:
      • AddPage (tab_background_color As Int, tab_text As String, tab_icon As B4XBitmap, tab_tag As Object, pager_layout As B4XView, pager_value As Object) As String
      • Initialize (TabMenu As com.as.tabstrip.astabmenu, ViewPager As com.as.tabstrip.asviewpager) As String
        Initializes the object. You can add parameters to this method if needed.
      • IsInitialized As Boolean
        Tests whether the object has been initialized.
      • RemovePage (index As Int) As String
      • TabMenu_TabClick (index As Int) As String
      • ViewPager_PageChanged (index As Int) As String
Hi Alexander Stolte
One suggestion for improving the library is to have a method that specifies the number of pages in ASTabStrip like:
B4X:
AsTabStrip1.PageCount
A function is also required to delete all pages in the ASTabStrip like:
B4X:
AsTabStrip1.RemoveAllPages
It is also better to have a method to detect the index of the current page like:
B4X:
AsTabStrip1.TopPageIndex
 
Top