TabHost Views

jnbarban

Member
Licensed User
Longtime User
Hi , Dou you know How to list all views of tabhost ?
i would like to resize by code all views on my tabHost.

I do this for Activity :

B4X:
For i = 0 to Activity.NumberOfView -1
    Dim MyView as View
    MyView  = Activity.GetView(i)
    MyView.SetLayout(MyView.Left*Ratio, MyView.Top*Ratio, MyView.Width*Ratio, MyView.Height*Ratio)
next

This code Work but if i have a tabhost in my activity, All view of this tab host was not resized...
 

Widget

Well-Known Member
Licensed User
Longtime User
Instead of adding the views to the TabHost directly with AddTab or AddTabWithIcon you should add the views to a Panel and then add the Panel to the TabHost with AddTab2 or AddTabWithIcon2. Then you will be able to iterate over the panels views.

Hi Erel,
I am just playing with TabHost for the first time and I can see the benefit of using a panel per page when you need to reference the Views. But why not just use the Designer to design a layout for each page of Tabhost and each of these layouts have their own panel like "pnlPage2". Then the user can still use the Designer to design each page and use AddTab or AddTabWithIcon to load the layout for the page. Otherwise wouldn't the user would have a stack of panels in the Designer or add all of the Views using code?

Widget
 
Upvote 0

Widget

Well-Known Member
Licensed User
Longtime User
Both options can work fine. Panels can load layouts themselves. So you can add the Panel by code and then call Panel.LoadLayout.

Erel,
That gives me an idea. I could have a large blank panel in the main activity with a small top panel that has buttons like "Home", "<" and ">" to act as a Navigator (see iPhone). The buttons would load in the Previous or Next layouts, much like a MS wizard. This gets rid of the large tabs in TabHost (as long as I name the Views properly) and allows me to have as many pages as I want. The next page can be called up conditional on some of the View value(s) in the current panel. Hmmm. By jove, I think I've got it. :D

Widget
 
Upvote 0
Top