The solution is quite simple actually.
You're populating the ListView
from a List
. The List
is an ordered collection of items, so when adding it as the datasource for the ListView
you will always know the index of each item.
So when selecting an item from the ListView
you get the position of the View
clicked. This position will correspond to the position in your List
.
You won't really need the id
field of your MyCustomDataObject
, but of course when you populate the List
of MyCustomDataObject
you could use a normal for-loop (not enhanced) and use the index to set the id of each MyCustomDataObject
.