I have a ListView which its contents could change at any time (eg. a list of cities within a state; a new city could be added to the state in our database at anytime). How do I implement, if possible, the onListItemClick event to work with this? For example, if a user selects a certain city in the ListView, i should be able to pass a value that independently identifies what city was clicked onto my next activity. I can’t listen for positions because they could change with an addition or removal of a city. Any suggestions?
Share
In this case you must write your own Adapter (for instance, extending the
BaseAdapter) and overwrite thegetItemIdmethod:The rest will be piece of cake since the
onListItemClickmethod gets that ID: