I have a list view in my android list activity which get data through a json file. In the list view I have to show the basic details of the item. When we click on a item I need
In your listener implementation you have reference to the View that was clicked, and in case of itemClick (or ExpandableList: groupClick / childClick) you also have the position of the underlying data inside your list.
So just use the position to retrieve the clicked data from the data structure you used to populate the list (adapter).
Update
If you have a ListActivity, in which the dataList member holds the values you are displaying in the list, you just override it's onListItemClick method:
/**
* The list of custom data you display in this activity
*/
private ArrayList dataList;
@Override
protected void onListItemClick(ListView l, View v, int position, long id)
{
super.onListItemClick(l, v, position, id);
final MyData selectedValue = dataList.get(position);
//TODO: deal with this selectedValue
}
API Docs for onListItemClick
This method will be called when an item in the list is selected. Subclasses should override.
Subclasses can call getListView().getItemAtPosition(position) if they need to access the data associated with the selected item.
Parameters:
l The ListView where the click
happenedv The view that was clicked within
the ListViewposition The position of the view
in the listid The row id of the item that was
clickedA complete example you can find on Android-er here and here.