Dynamically Adding Scroll Views To Tabs

iCAB

Well-Known Member
Licensed User
Longtime User
Hi Guys
I am new to Basic4Android and I would realy appreciate some help.
I am looking at 2 sample codes TabHostExtra & ScrollViewExample. I would like to be able to use a combination of the 2 examples in a way to display in each table a scroll view. My question is how to add the scroll views dynamically to each Tab and how to address them properly in code properly.

My Other question is:
in Activity_Create of the TabHostExtraDemo you use Button1.Tag = 1; How does the compiler know which button1 you are addressing ( The one on the first Tab, or the second Tab ). can someone please clarify

Thank you
 

klaus

Expert
Licensed User
Longtime User
You should have a look at this example: TabHostScrollViews.

There is no problem with the Button1.Tag, the name of the Button doesn't matter. In the Button1_Click routine the Sender object holds the reference to the Button that raised the event.

Best regards.
 
Upvote 0

iCAB

Well-Known Member
Licensed User
Longtime User
Hi Klaus

Thanks for the reply. Great help.

The only thing that I am still looking for is how can I headers to the scroll views similar to the ScrollViewExample.

Also when I mentioned about Button1, I was referring to the this part of the code ( there is no sender in here ). Can you please clarify

For i=0 To TabCount-1
If i=0 Then
TabHost1.AddTab("Tab#"&i, "LayoutWebView")
WebView1.LoadUrl("http://www.google.co.uk/")
Else
TabHost1.AddTab("Tab#"&i, "LayoutTabContent")

Button1.Tag=i
If TabsEnabled(i) Then
Button1.Text="Disable this tab"
Else
Button1.Text="Enable this tab"
End If
EnableButtons(i)=Button1

Button2.Tag=i
If TabsVisibility(i) Then
Button2.Text="Hide this tab"
Else
Button2.Text="Show this tab"
End If
ShowHideButtons(i)=Button2

Edittext1.Text=TabHeight
Label1.Text="This is TabContent #"&i
End If
Next

Thanks for all the help
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
The only thing that I am still looking for is how can I headers to the scroll views similar to the ScrollViewExample.
You have everything you need in the ScrollViewExample. Or have a look at this example.

Also when I mentioned about Button1, I was referring to the this part of the code ( there is no sender in here ). Can you please clarify
I know that in the code fragment you are refering to there is no Sender keyword. In this code fragment the name of the buttons are those defined in the layout file. But each time the layout file is loaded, new instances of Button1 and Button2 are initiated and the previous names are no longer known by the system but they are known with an internal reference. All Button1 buttons have the same event routine. For example, in the event routine Button1_Click you need to know what Button raised the event and here the reference is given by the Sender object.

Best regards.
 
Upvote 0

iCAB

Well-Known Member
Licensed User
Longtime User
Hi Klaus

Thanks for all the help.
I am having problem getting the scroll view to scroll.
Is it possible for me to e-mail you a zip file for the project ( it is very small ).

Please let me know

Thanks
 
Upvote 0

iCAB

Well-Known Member
Licensed User
Longtime User
Hi Klaus

Is there a way to change the background and Foreground Colors for the current Tab?

Thanks
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Is there a way to change the background and Foreground Colors for the current Tab?
What colors do you want to change ?
The colors of the colors in the ScrollViews ?
The ScrollView colors can be chaged with:
B4X:
svcViewsGUIParm(0).CellColor = Colors.RGB(255,255,220)
svcViewsGUIParm(0).FontColor = Colors.Red
svcViewsGUIParm(0).LineColor = Colors.Blue
Best regards.
 
Upvote 0

iCAB

Well-Known Member
Licensed User
Longtime User
Sorry, I didn't see your reply before.
I didn't notice that there is Next Page on the forum.

Thank you for the reply
 
Upvote 0
Top