Android Question [AS Chips] Chips inside a customlistview

yiankos1

Well-Known Member
Licensed User
Longtime User
Hello,

If i add chips inside a clv item then "+2 chip" (or whetever number), is at the begining instead of the end, at the top of the first visible chip.

Screenshot_20250108-130904 (1).png


Here is the code CLV and PreoptimizedCLV:
B4X:
Private Sub clvGym_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
  
    For Each i As Int In PCLVgyms.VisibleRangeChanged(FirstIndex, LastIndex)

        Dim item As CLVItem = clvGym.GetRawListItem(i)
        Dim pnl As B4XView = xui.CreatePanel("")
        item.Panel.AddView(pnl, 0, 0, item.Panel.Width, item.Panel.Height)
        Dim gymData As gym = item.Value
        'Create the item layout
        pnl.LoadLayout("clvGym")
          
        #if b4a
        MediaManager.SetMediaWithExtra(pnl.GetView(0).GetView(0),$"${B4XPages.MainPage.downloadLink}?name=${gymData.photo}.jpg"$,"image/*",CreateMap(MediaManager.REQUEST_ROUNDIMAGE:True,MediaManager.REQUEST_HEADERS: CreateMap("command":"image","id": B4XPages.MainPage.user.id,"token":B4XPages.MainPage.user.token)))
        #else
        misc.DownloadAndSetImage(ImageLoader,gymData.bitmap,gymData.photo,gymData.id,pnl.GetView(0).GetView(0).tag)
        #End If
      
        pnl.GetView(0).GetView(1).Text = gymData.name
      
        Private chipType As AS_Chips = pnl.GetView(0).GetView(2).Tag
      
        chipType.ChipPropertiesGlobal.BackgroundColor = xui.Color_White
        chipType.ChipPropertiesGlobal.TextColor = xui.Color_Black
      
        For i = 0 To gymData.gymType.Size-1
            If gymData.gymType.Get(i)<>"null" Then
                chipType.AddChip(gymData.gymType.Get(i),misc.FontToBitmap(misc.Chr32(0xF1300),32,xui.Color_Black),"")
            End If
        Next
      
        Sleep(0)
      
        chipType.RefreshChips
              
        cs.Initialize.Color(xui.Color_RGB(255,172,11)).Append($"★ $1.2{gymData.all_time_rating}"$).Pop.Append($" (${gymData.total_ratings})"$).PopAll
      
        #if b4a
        pnl.GetView(0).GetView(3).Text = cs '$"★ $1.0{gymData.all_time_rating} (${gymData.total_ratings})"$
        #else
        pnl.GetView(0).GetView(3).As(Label).AttributedText = cs
        #End If
      
      
    Next
  
    #if b4a
    MediaManager.TrimMediaCache
    #End If
  
    End If
End Sub

Same behavior b4a and b4i
 

Alexander Stolte

Expert
Licensed User
Longtime User
If i add chips inside a clv item then "+2 chip" (or whetever number), is at the begining instead of the end, at the top of the first visible chip.
I assume that you still have the “AutoScale” in the Designer in the designer script for the item in the list.
 
Upvote 0

yiankos1

Well-Known Member
Licensed User
Longtime User
I assume that you still have the “AutoScale” in the Designer in the designer script for the item in the list.
Hello Alexander,

Thank you for your reply,

AutoScale is disabled in b4i. In b4a is enabled, but the result is the same even it is not.

I see some inconsistency between my devices:

Pixel 7 Pro working fine
1000040817.png


In b4i results are the same as the Huawei device(OP).

Does it come anything into your mind to try, in order not to bother you.
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
Well, the +1 or +2 is displayed if not all chips fit.

To avoid this, either use the AS_ScrollingChips or switch on the automatic growth:
1. Enable "Auto Expand" in the designer
2. Add the HeightChanged event and adjust the height of the list item
 
Upvote 0
Top