Android Question CustomListView floating titles - button

kisoft

Well-Known Member
Licensed User
Longtime User
Hi
I would like to use this very nice solution..
.https://www.b4x.com/android/forum/threads/xui-customlistview-with-floating-titles.87935/#content
How to add additional elements? , for example, a button, image, to the drop-down list.

B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    pnlTitle.Visible = False
    pnlTitle.SetLayoutAnimated(0, 0, 0, CLV1.AsView.Width, TitleHeight + DividerHeight)
    pnlTitle.LoadLayout("CellTitle")
    AddTitle("Title #AAA")
    For i = 1 To 10
        CLV1.AddTextItem($"A) Item #${i}"$, "")
    Next
    AddTitle("Title #BBB")
    For i = 11 To 21
        CLV1.AddTextItem($"B) Item #${i}"$, "")
    Next
    AddTitle("Title #CCC")
    For i = 22 To 32
        CLV1.AddTextItem($"C) Item #${i}"$, "")
    Next
    CLV1_ScrollChanged(0)
End Sub
 

kisoft

Well-Known Member
Licensed User
Longtime User
HI
I think I succeeded. It works somehow. Unfortunately, the list is slowly starting up.

B4X:
Sub Activity_Create(FirstTime As Boolean)
   
    Activity.LoadLayout("1")
    pnlTitle.Visible = False
    pnlTitle.SetLayoutAnimated(0, 0, 0, CLV1.AsView.Width, TitleHeight + DividerHeight)
    pnlTitle.LoadLayout("CellTitle")
    AddTitle("Title #AAA")
    For i = 1 To 10
    CLV1.Add(CreateListItem(100%x,10%y),i)
    Next
    AddTitle("Title #BBB")
    For i = 11 To 21
       CLV1.Add(CreateListItem(100%x,10%y),i)
    Next
    AddTitle("Title #CCC")
    For i = 22 To 32
        CLV1.Add(CreateListItem(100%x,10%y),i)
    Next
    CLV1_ScrollChanged(0)
 End Sub

Sub CreateListItem(Width As Int, Height As Int) As Panel

    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0, 0, 0, Width, Height)
    p.LoadLayout("2")
    Return p

End Sub
 
Last edited:
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(
0, 0, 0, Width, Height)
p.LoadLayout(
"2")
Return p

I think some lazy loading logic may help here, as you are creating the layout of all the items at first.

Regards,

Anand
 
Upvote 0

kisoft

Well-Known Member
Licensed User
Longtime User
I tried to move the Activity Create part to another sub, but this only slows down the loading of the layout.
 
Upvote 0
Top