Android Question TabStrip and CsBuilder

MarcoRome

Expert
Licensed User
Longtime User
Hi All. I have this code:
B4X:
    Dim cs1 As CSBuilder
    cs1.Initialize
    'cs1.Color(xui.Color_Black).Append("TEST").PopAll
    cs1.Image(LoadBitmap(File.DirAssets, "img_trash_yellow.png"), 40dip, 40dip, False).Append(CRLF).PopAll
    
    Label1.Text = cs1
    TabStrip1.LoadLayout("lay0", cs1)

Into Label1 work without problem, but in TabStrip1 dont work.
In attachment example.
Any suggestion ??
Thank you very much
Marco
 

Attachments

  • TabStripCSBuilder.zip
    12.8 KB · Views: 99

Mahares

Expert
Licensed User
Longtime User
Any suggestion ??

B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout")    
    TabStrip1.LoadLayout("lay0", "")    
    Dim cs1 As CSBuilder
    cs1.Initialize
    cs1.Image(LoadBitmap(File.DirAssets, "img_trash_yellow.png"), 40dip, 40dip, False).Append(CRLF).PopAll    
    Label1.Text = cs1
    
    Dim l As Label = GetAllTabLabels(TabStrip1).Get(0)   'get(0) is 1st tab label, Get(1) will be the 2nd label
    l.Text=cs1    
End Sub
Public Sub GetAllTabLabels (tabstrip As TabStrip) As List   'need reflection and javaobjet libs
    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)
        If v.Tag Is Label Then res.Add(v.Tag)
    Next
    Return res
End Sub
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
Thank you @Mahares.
I had already seen this solution


I don't understand why it doesn't work with csbuilder since the value is passed as CharSequence
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
According to post 17 here: the CSBuilder needs to be implemented after the tabstrip tabs are created not before
Added this a few minutes later: Here is another example with 3 pages.
B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout")   
    Dim cs1 As CSBuilder
    cs1.Initialize
    cs1.Image(LoadBitmap(File.DirAssets, "img_trash_yellow.png"), 40dip, 40dip, False).Append(CRLF).PopAll   
    Label1.Text = cs1
    TabStrip1.LoadLayout("lay0", "")
    TabStrip1.LoadLayout("lay1", "")
    TabStrip1.LoadLayout("lay2", "")
   
    For Each l As Label In GetAllTabLabels(TabStrip1)
        l.Text = cs1
    Next
End Sub
 
Last edited:
Upvote 0
Top