Android Question [Solved] Using AS_Chips in a CustomListView

asales

Expert
Licensed User
Longtime User
I use the AS_Chips library from @Alexander Stolte.

I have dozens of chips and I want to use this library in a CustomListView to scroll the chips, but I can't adjust the size of the chip list.

An example is attached.
If I put 50 chips, there is a gray space below.
If I put 150 chips, it only shows 81.
1726663847760.png
1726663883346.png

How can I adjust the chips in a customlistview and show all the chips.

Thanks in advance for any tips.
 

Attachments

  • ProjectASChipsCLV.zip
    184 KB · Views: 23
Solution
A few tips:
  1. Set the "Insert Animation Duration" to 0 in the designer for the CustomListView
  2. Add the layout item with a small height to the list e.g. 20dip
  3. Adjust the height of the list item in the AS_Chips_HeightChanged event
  4. Done
Example:
B4X:
    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0,0,0,Root.Width,20dip) 'We adjust the height of the list item later in the HeightChanged Event
    p.LoadLayout("laychips")
    CustomListView1.Add(p, -1)  'ide://goto?Layout=laychips
    
    For i = 1 To 100 -1   
        AS_Chips2.ChipPropertiesGlobal.BackgroundColor = xui.Color_White
        AS_Chips2.ChipPropertiesGlobal.TextColor = xui.Color_Black
        AS_Chips2.AddChip("Test " & i...

Alexander Stolte

Expert
Licensed User
Longtime User
A few tips:
  1. Set the "Insert Animation Duration" to 0 in the designer for the CustomListView
  2. Add the layout item with a small height to the list e.g. 20dip
  3. Adjust the height of the list item in the AS_Chips_HeightChanged event
  4. Done
Example:
B4X:
    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0,0,0,Root.Width,20dip) 'We adjust the height of the list item later in the HeightChanged Event
    p.LoadLayout("laychips")
    CustomListView1.Add(p, -1)  'ide://goto?Layout=laychips
    
    For i = 1 To 100 -1   
        AS_Chips2.ChipPropertiesGlobal.BackgroundColor = xui.Color_White
        AS_Chips2.ChipPropertiesGlobal.TextColor = xui.Color_Black
        AS_Chips2.AddChip("Test " & i, AS_Chips2.FontToBitmap(Chr(0xE0C8),True,30,xui.Color_Black),"")       
    Next
    AS_Chips2.RefreshChips
B4X:
'Only affected if AutoExpand = True
Private Sub AS_Chips2_HeightChanged (Height As Float)
    Log("HeightChanged: " & Height)
    CustomListView1.ResizeItem(0,Height)
End Sub
 

Attachments

  • AS_Chips Example_CLV.zip
    180.1 KB · Views: 19
Upvote 2
Solution
Top