Hi to All,
About AddTwoLinesAndBitmap2 documentation says: "The specified return value will be returned when calling GetItem or in the ItemClick event"
Using GetItem I'm able to obtain the ReturnValue but how to obtain the ReturnValue within the ItemClick event ?
What is the code you are using?
The ItemClick Event will give you a parameter value. This is the value you set with AddTwoLinesAndBitmap2 in the last parameter,
My target is to associate an Item ID to each listview item.
So the sintax is:
B4X:
AddTwoLinesAndBitmap2 (Text1 As String, Text2 As String, Bitmap As android.graphics.Bitmap, ReturnValue As Object)
For example:
B4X:
private ItemID as object
ItemID = 1
AddTwoLinesAndBitmap2 ("This is item n.1", "", aImg, ItemID)
ItemID = 2
AddTwoLinesAndBitmap2 ("This is item n.2", "", aImg, ItemID)
ItemID = 3
AddTwoLinesAndBitmap2 ("This is item n.3", "", aImg, ItemID)
After I wish to be able to obtain the item ID using .GetItem or within an _ItemClick event.
In this case I wish to have the displayed text (for user) and the hidden ID for items lookup.
Rnd number is to simulate the SQLite incremental ID that I have to store within the listview item.
So I have a mapping between Item Text ("This is item n...") and the Record ID (SQLite incremental ID).
The ID I wish to put is the SQLite record ID related to the item.
So the item value is the text displayed within the listview to the user and the Record ID is stored within the ReturnValue object.
Is it possible ?
P.S.
Could be that I don't understand well the documentation
Probably @Erel could give a clear explanation about it.
No.
Create a global list
For each item you add put the itemtext to this list.
In you item click event you get the item from your list with th position "Position"
If you want to get teh ItemID and the text as the return value you could define a Type variable which holds both values.
When you click onto an item you'll get the Type value back. You can then get the text and the ItemID.
In my database projects I use a separte List with the rowIDs.
I fill a Spinner with the texts and a list with the rowIDs.
For a given position I know the text and the rowID.