I have a ListView that is populated using an XML file. However, I want each item, when clicked, to start a new Activity related to that item.
I understand how to use OnItemClick to start a Toast that shows the selected item’s text. However, since the ListView is populated from an XML there is not a specific Id for each item in the list.
So, how would I associate an Activity with each item in the ListView when the items do not have Ids?
Maintain in your XML file a node for the Activity that has to be called, in a numeric or string format. Then have a list of activities in a collection, that are implementing a certain interface/abstract class, so that you can loop on it. Also activities have a static field/method that return their reference number or string so you can compare too.
Some sketch:
In Java:
where
getTag()returns the identifier for the class eg:grp1orgrp2