Reputation: 3155
I am working on a CRM app in android, in which, I am showing details of all contacts in a list view. Now, my requirement is when I click on a particular item in the list, it should only display the details about selected contact, such as, name, address, email, etc.. The data is coming from XML file, which I am parsing using SAX Parser. How can I query a XML to get selected data?
Upvotes: 0
Views: 125
Reputation: 13327
You are filling the ListView
using Adapter
right? Now you can get the item at the selected view inside the ListView
and pass this item to an Activity
.
E.g. inside your Adatper
class implement the onItemClickListener
:
public void onItemClick(AdapterView<?> a, View v, int position, long l) {
// Remembers the selected Index
Data item =getItem(position);
Intent intent = new Intent(getApplicationContext(), DetailedActivity.class);
intent.put("object",item);
startActivity(intent);
}
Note: the item "Data" class should implement the Parsable
interface so it can be passed to the Activity
in your DetailedActivity
onCreate
method get that object and update the UI
based on its Values.
Upvotes: 1