Android Question Programmatically create tab strips

apty

Active Member
Licensed User
Longtime User
I am trying to create tabstrips that will be based on a list. The list will contain items (basically strings) added by users. For each tabstrip i want to create a button per item on the list.The buttons will basically have a width of 40dip and height of 40dip. So each tabstrip will hold something like (Activity.width/button.width)*(Activity.height/button.height) buttons.

Because i don't know how many items will be added to the list, how can i loop through the list and add a tabstrip that basically holds (Activity.width/button.width)*(Activity.height/button.height) buttons?

I can loop through the list and create the buttons but i need another loop that creates the tabstrips that will hold the buttons. Kindly assist
 
Last edited:

apty

Active Member
Licensed User
Longtime User
Yeah. The page can be the same but in order to hold the buttons, i need several tab strips. I can do it with a scrollview and one tabstrip but i dont want the users to scroll down the page in order to see the buttons, i want them to swipe instead.
 
Last edited:
Upvote 0

apty

Active Member
Licensed User
Longtime User
I have tried but my app keeps crushing. I tried switching to sliding panels class. Suppose i have the code below:
B4X:
For i = 0 To panels.Length - 1
        panels(i).Initialize("panels")
        panels(i).Color = Colors.RGB(Rnd(0, 255), Rnd(0, 255), Rnd(0, 255))
        Dim btn As Button
        btn.Initialize("")
       btn.Text = "I'm Panel: " & i
        btn.TextSize = 20
        btn.TextColor = Colors.White
        panels(i).AddView(btn, 20%x, 40%y, 60%x, 30dip)
        Activity.AddView(panels(i), 100%x, 0, 100%x, 100%y - 60dip)
       
    Next

instead of having one button per panel, how can i have at least 20 buttons per panel?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…