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

yiankos1

Well-Known Member
Licensed User
Longtime User
Have you found a solution?
Or was it not the right one?
Hello Alex,

Untill now I can't figure out the reason behind of this.

Unfortunately, I can't use height change event because items created at visiblerange event of Preoptimised CLV. So, I don't know which index is the item that raised height change event, in order to change height accordingly.

Scrolling chips is an option, but when a user clicking on a gym item, next page shows more details of the gym and all the chips. So, I am not sure if I want to show all gym types at CLV item.

I am curious why it is working fine on a pixel and not on an old android device and on a iPhone 7.

For now, I have moved on with current chips, because the deadline is too strict.

App is on an open beta test if you want to test it. But there are two downturns, it's only in Greek language and until now it's only available for Android.

Thank you again for your interest.
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
I don't know which index is the item that raised height change event
yes, you can determine at any time on which index a view is in the list:
B4X:
Private Sub xChip_HeightChanged (Height As Float)
    Dim xChip As AS_Chips = Sender
    Dim Index As Int = xclvNotes.GetItemFromView(xChip.mBase)
    xclvNotes.ResizeItem(Index,xChip.mBase.Height)
    
End Sub
App is on an open beta test if you want to test it. But there are two downturns, it's only in Greek language and until now it's only available for Android.
I have a Nothing Phone 2 as an Android development device. Together with the live google translator I can already use it ^^
 
Upvote 0

yiankos1

Well-Known Member
Licensed User
Longtime User
, you can determine at any time on which index a view is in the list:
Indeeeeeeed!!! Never thought about sender object! Good catch!

Here is a beta test url:

If you have any recommendations, bugs, errors please send me a private message. It's an honor spending time testing my app. Thank you again.

At upcoming days I will make a post for this application(webapp, iOS, Android)
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
Upvote 0

yiankos1

Well-Known Member
Licensed User
Longtime User
unfortunately i can't download it, google play says it's not available in my country
Ooooh sorry. Just added Deutschland right?

Waiting for review, maybe tomorrow will be ready.

am very excited about the ios version
A sneak peek: it's like sugarwod app (social fitness app) but has much more features like diets, gym booking, webapp CRM.

Took me about a year and a half to "finish" this project. (Server, SQL database, webapp, iOS, Android, landing page)
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
Just added Deutschland right?
Yes :) Thank you

A sneak peek: it's like sugarwod app (social fitness app) but has much more features like diets, gym booking, webapp CRM.

Took me about a year and a half to "finish" this project. (Server, SQL database, webapp, iOS, Android, landing page)
I'm very excited about it, especially because I also have a gym app. I can well imagine that this was a lot of work
 
Upvote 0
Top