Android Question ScrollView in TabHost

Sinan Tuzcu

Well-Known Member
Licensed User
Longtime User
Hallo,

i create with the following code a Scrollview with some Buttons and Labels.
I want to add this Scrollview in a Tabhost.

Who knows how this it works?
Who can help me?

Code for create Scrollview:
B4X:
ScrollView1.Initialize(193dip * 10) 'Innere Höhe definieren (nicht sichtbar)
    Activity.AddView(ScrollView1, 2%x, 30%y, 96%x, 65%y) 'Sichtbare Linkaabstand, Obenabstand, Breite, Höhe definieren
    For i = 0 To 31 'Relais Anzahl definieren von 0 bis 31 sind 32 Relais
        Dim p As Panel
        p.Initialize("")
        p.Tag = i
        p.LoadLayout("relais")
        For v = 0 To p.NumberOfViews - 1
            p.GetView(v).Tag = p 'set the panel as the Tag value
        Next
        ScrollView1.Panel.AddView(p, 0, i * 60dip, ScrollView1.Panel.Width, 58dip)
    Next

thanks in advance
Sinan
 

josejad

Expert
Licensed User
Longtime User
Look the TabHost example: https://www.b4x.com/android/forum/threads/tabhost-tutorial.6721/

You should add the TabHost, and then AddTab's. One of the TAB should be the scrollview you want to add

B4X:
    TabHost1.AddTabWithIcon ("Name", bmp1, bmp2, "page1") 'load the layout file of each page
    TabHost1.AddTab("Color", "page2")
    TabHost1.AddTab("Animal", "page3")
 
Last edited:
Upvote 0

Sinan Tuzcu

Well-Known Member
Licensed User
Longtime User
Solved:

B4X:
Sub Relais_In_ScrollView
    ScrollView1.Initialize(193dip * 10) 'Innere Höhe definieren (nicht sichtbar)
    Activity.AddView(ScrollView1, 2%x, 30%y, 96%x, 68%y) 'Sichtbare Linkaabstand, Obenabstand, Breite, Höhe definieren
    For i = 0 To 31 'Relais Anzahl definieren von 0 bis 31 sind 32 Relais
        Dim p As Panel
        p.Initialize("")
        p.Tag = i
        p.LoadLayout("relais1")
        For v = 0 To Relais - 1
            p.GetView(v).Tag = p 'set the panel as the Tag value
        Next
        ScrollView1.Panel.AddView(p, 0, i * 60dip, ScrollView1.Panel.Width, 58dip)
    Next
    
End Sub

Sub Opto_In_ScrollView
    ScrollView2.Initialize(193dip * 10) 'Innere Höhe definieren (nicht sichtbar)
    Activity.AddView(ScrollView2, 2%x, 30%y, 96%x, 68%y) 'Sichtbare Linkaabstand, Obenabstand, Breite, Höhe definieren
    For i = 0 To 31 'Relais Anzahl definieren von 0 bis 31 sind 32 Relais
        Dim p As Panel
        p.Initialize("")
        p.Tag = i
        p.LoadLayout("relais2")
        For v = 0 To p.NumberOfViews - 1
            p.GetView(v).Tag = p 'set the panel as the Tag value
        Next
        ScrollView2.Panel.AddView(p, 0, i * 60dip, ScrollView2.Panel.Width, 58dip)
    Next
    ScrollView2.Visible=False
End Sub

and make
ScrollView2.Visible=False
 
Upvote 0
Top