Bug? TabHost with the same layout on each tab?

ac9ts

Active Member
Licensed User
Longtime User
I am not sure if this is a bug or a limitation or I'm just not using it correctly.....

I have a 4 tabs and would like to use the same layout on each of them. The layout would have all the views I intend to use with generic names (btnR1, btnR2, lstSelection.......). The plan was to just change the text on buttons, hide/show views, etc. depending on which tab is selected. The view callbacks would check which tab is selected and act accordingly. When I attempt to do it, the layout only shows on the last tab added. The first 3 are blank. I am using v2.71

B4X:
TabHost1.AddTab("Tab1", "CommonLayout")            ' Tab 0 blank
TabHost1.AddTab("Tab2", "CommonLayout")            ' Tab 1 blank
TabHost1.AddTab("Tab3", "CommonLayout")            ' Tab 2 blank
TabHost1.AddTab("Tab4", "CommonLayout")            ' Tab 3 shows the layout
 

klaus

Expert
Licensed User
Longtime User
This is normal.
You load four times the same layout with the same names for the views in the same activity.
This means that only the last instances of the views are recognized by the system.
Do you need the TabHost ? You could use one layout and Buttons to update the layout according to your needs.
 

ac9ts

Active Member
Licensed User
Longtime User
Thanks Klaus. That's what I thought was happening. I've got a lot of items to handle and the tabs helped on small screen sizes. Tablets are not a problem. They will have a different layout. I suppose I could re-do the layout without tabs. That may actually solve another problem where I was having issues with the tab text being different sizes across the various devices. I believe there is a way to scale button text but I couldn't find one for the tab host tab labels. Back to a new design!
 
Top