Android Question Using Single Scrollview layout with Tabstrip

JohnC

Expert
Licensed User
Longtime User
Hi Erel,

I really appreciate the sample from this thread (https://www.b4x.com/android/forum/threads/scrollview-tabstrip.70184/#post-446361) and I see the trick you are using.

But, I would like to have more then just scrollable text displayed on each tab - I would like to have a checkbox or two and other views that should also scroll. Meaning, I would like the flexibility of loading a "layout" into the scrollview, instead of just being limited to text.

Is there any way to modify the below routine so it will return a list of all the scrollviews in the tabstrip so I can then access them and load a different layout into each one:

B4X:
Public Sub GetAllTabLabels (tabstrip As TabStrip) As List
   Dim jo As JavaObject = tabstrip
   Dim r As Reflector
   r.Target = jo.GetField("tabStrip")
   Dim tc As Panel = r.GetField("tabsContainer")
   Dim res As List
   res.Initialize
   For Each v As View In tc
     If v Is Label Then res.Add(v)
   Next
   Return res

End Sub
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Please don't limit your questions to a single member.

GetAllTablLabels has nothing to do with the tab pages content.

I really appreciate the sample from this thread (https://www.b4x.com/android/forum/threads/scrollview-tabstrip.70184/#post-446361) and I see the trick you are using.
There is no trick here. Each layout in this example is made of a CustomListView. You can create whichever layout you like and load it. You can also create a layout with ScrollView and then load another layout to the scrollview with ScrollView.Panel.LoadLayout.
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
There is no trick here. Each layout in this example is made of a CustomListView. You can create whichever layout you like and load it. You can also create a layout with ScrollView and then load another layout to the scrollview with ScrollView.Panel.LoadLayout.[/QUOTE said:
But, that's what I don't know how to do....

I know I could do this:

B4X:
Dim SV1 as Scrollview   'which is the sv in the "Help-SV1" layout
Dim SV2 as Scrollview   'which is the sv in the "Help-SV2" layout
Dim SV3 as Scrollview   'which is the sv in the "Help-SV3" layout

TabStrip1.Loadlayout("Help-SV1","Page 1")
TabStrip1.Loadlayout("Help-SV2","Page 2")
TabStrip1.Loadlayout("Help-SV3","Page 3")

SV1.LoadLayout("Page1")
SV2.LoadLayout("Page2")
SV3.LoadLayout("Page3")

But the above code requires me to have SIX different layouts.

For efficiency, I would like to just have one scrollview layout that I would reuse it on each page of the tabstrip, something like this:

B4X:
Dim SV as Scrollview
TabStrip1.Loadlayout("Help-SV","Page 1")
TabStrip1.Loadlayout("Help-SV","Page 2")
TabStrip1.Loadlayout("Help-SV","Page 3")

Then I would like to be able to do something like this:

B4X:
Dim L as List
L.Initialize

L = GetAllScrollViews(TabStrip)
L(0).Panel.LoadLayout("Page 1")
L(1).Panel.LoadLayout("Page 2")
L(2).Panel.LoadLayout("Page 3")

Which would then only require 4 layouts.

That's why I was wondering if your GetAllTablLabels routine could be modified to instead return a list of the three scrollviews that were loaded into the tabstrip so I could access each one separately and load a different layout into each.

But if you are saying that I can use the CustomListView and load a layout into it (instead of a scrollview) using what I called a "trick" because I don't totally understand how the below code works to access just a single view out of the 5 views loaded in your sample:

B4X:
CustomListView1.AddTextItem($"Page: #${i} This is a test "$, "")

Then I would be very interested in seeing how I could do that.
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Ah! I see what you did - the odd looking line in your sample (I say odd because I haven't used the ${} symbols yet to know exactly what they do):

B4X:
CustomListView1.AddTextItem($"Page: #${i} blahblahblah. "$, "")

Wasn't some weird code to directly access an individual CustomListView1 on just one of the pages. It was just accessing the MOST RECENTLY loaded CustomListView1.

So using this method I could just have one ScrollView dimmed and as I load in the same layout (that has the sv on it) into each page of the tabstrip, the ScrollView object is temporarily linked to the scrollview view of the latest page that was just loaded with "TabStrip1.LoadLayout("svlayout").

So I just need to immediately load the appropriate layout into the scrollview before another page is added, because otherwise the scrollview object will then point to the new page's sv object and will no longer be directly accessible after that new page is loaded into the tabstrip.

Now I got it.

So basically, I should be able to do this:

B4X:
Dim SV as Scrollview   'which is the sv in the "Help-SV" layout

TabStrip1.Loadlayout("Help-SV","Page 1")
SV.Panel.LoadLayout("Page1")
TabStrip1.Loadlayout("Help-SV","Page 2")
SV.Panel.LoadLayout("Page2")
TabStrip1.Loadlayout("Help-SV","Page 3")
SV.Panel.LoadLayout("Page3")
 
Upvote 0

Lee Ingram

Member
Licensed User
Longtime User
I am now trying to use CustomListView with TabStrip. It is working for me a little. I would like each Page of text to be a different Color.
I can change the text size and and color, but I would like to change the page background color. I am trying to figure out how to use buttons also.
clv1.DefaultTextColor = Colors.Blue.
clv1.DefaultTextSize = 24

B4X:
Activity.LoadLayout("Main")
    Activity.Title= "PAIRING   CONNECTION   ZERO/CAL HELP"
    clv1.Initialize(Me,"clv1")
    pnl1.Initialize("clv1")
       
    '=========================Pairing==================
    TabStrip1.LoadLayout("Page","-PPS TOOL PAIRING-")
        clv1.DefaultTextBackgroundColor=Colors.Cyan
        'clv1.sv.Color = 0xFFD9D7DE
    clv1.DefaultTextColor = Colors.Blue
    clv1.DefaultTextSize = 24
    clv1.DefaultTextBackgroundColor = Colors.Black
    clv1.BackgroundColor(Colors.Red)
    clv1.AsView.Color = Colors.Cyan
    pnl1.Color=Colors.Cyan
   
    clv1.AddTextItem("   -2x2 PAIRING-", "a")
   
    clv1.AddTextItem($"
        1) go To settings
        2) Select Bluetooth
        3) click on only visible To paired devices
        4) click scan
        5) click on available devices   like: WHT_207AJ08313
        6) enter password  ( 61735)
        "$, "")
    clv1.AddTextItem("  -4x4-PAIRING-", "a")
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
If you really want to make the pages look great, you could use a webview instead of a label or CustomListView. All you would do is load HTML code into it and make it look as sharp as you want.
 
Upvote 0

Lee Ingram

Member
Licensed User
Longtime User
If you really want to make the pages look great, you could use a webview instead of a label or CustomListView. All you would do is load HTML code into it and make it look as sharp as you want.
Thanks I'll take a look at WebView.
Update
I like what I have been able to do with CustomView/TabStrip. I just need to be able to make each page background a different color. I currently have five pages. I can't seem to get or understand why this isn't working.
clv1.BackgroundColor(Colors.Red)
clv1.DefaultTextBackgroundColor=Colors.Cyan
Neither one of these seen to work??
 
Last edited:
Upvote 0

Lee Ingram

Member
Licensed User
Longtime User
I like what I have been able to do with CustomView/TabStrip. I just need to be able to make each page background a different color. I currently have five pages. I can't seem to get or understand why this isn't working.
clv1.BackgroundColor(Colors.Red)
clv1.DefaultTextBackgroundColor=Colors.Cyan
Neither one of these seen to work??
 
Upvote 0
Top