Android Question [Solved] CustomListView - Get item value

aeric

Expert
Licensed User
Longtime User
From this tutorial: [B4X] [XUI] CustomListView - lazy loading / virtualization

B4X:
Type CardData (Title As String, Content As String, BitmapFile As String, Color As Int) 'new Color field

B4X:
Sub CLV1_ItemClick (Index As Int, Value As Object)
   UpdateItemColor(Index, Rnd(0xff000000, 0xffffffff))
End Sub

How I can read the Value in CardData such as Title or Content when I click on an item ?
 

rraswisak

Active Member
Licensed User
i believe sample from link you provided show us how to set and read custom type value, just read carefully

Set value:
B4X:
...
 Dim cd As CardData
       cd.Initialize
       cd.Title = $"This is item #${i}"$
       cd.Content = content
       cd.BitmapFile = bitmaps.Get((i - 1) Mod bitmaps.Size)
       Dim p As B4XView = xui.CreatePanel("")
       p.SetLayoutAnimated(0, 0, 0, CLV1.AsView.Width, 280dip)
       CLV1.Add(p, cd)
...

read value:
B4X:
...
 Dim cd As CardData = CLV1.GetValue(i) 'change i with index parameter from ItemClick event
      p.LoadLayout("Card1")
      lblTitle.Text = cd.Title
      lblContent.Text = cd.Content
...
 
Upvote 0
Top