Android Question Multiple values in custom list view

frenkipi

Member
Licensed User
Longtime User
Hello, I am trying to add another Value in my custom list view.

B4X:
clv2.Add(CreateListItem($"Item #${i}"$, clv2.AsView.Width, 70dip), 70dip, $"Item #${i}"$, "another value"&i)

I was trying with modifying customListView class.... and I get an error:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
An error occurred:
(Line: 212) Log(CallSub3(CallBack, EventName & "_ItemClick",
java.lang.Exception: Sub clv2_itemclick signature does not match expected signature.
public static anywheresoftware.b4a.pc.RemoteObject anywheresoftware.b4a.samples.customlistview.main_subs_0._clv2_itemclick(anywheresoftware.b4a.pc.RemoteObject,anywheresoftware.b4a.pc.RemoteObject,anywheresoftware.b4a.pc.RemoteObject) throws java.lang.Exception

I have uploaded an example project.


Thank you for your help!
 

Attachments

  • CustomListView.zip
    61.5 KB · Views: 156

mangojack

Expert
Licensed User
Longtime User
Use a map to store as many 'values' as you want for each row item ...

B4X:
For i = 1 To 5
   Dim myMap As Map
   myMap.Initialize
   myMap.Put("value1",  $"First value for Item #${i}"$)
   myMap.Put("value2",  $"Second value for Item #${i}"$)
  'myMap.Put (......................
   clv1.Add(CreateListItem($"Item #${i}"$, clv1.AsView.Width, 70dip), 70dip, myMap)
Next

Sub clv1_ItemClick (Index As Int, Value As Object)

    Dim m As Map = Value
    Log(m.Get("value1"))
    Log(m.Get("value2"))

End Sub
 
Upvote 0
Top