I have a scenario here,i want to pass the desired json object on the list item click in my below activity
If you want it to be more flexible, you can put the JSON data you will pass in an ArrayList
and get()
the data you want to pass automatically depending on the item clicked like so:
ArrayList jsonList = new ArrayList();
jsonList.add(jsonDataForFirstListitem); // JSON data in String form
jsonList.add(jsonDataForSecondListitem);
// And so on...
Then for your listener, you can simply put it right after you define your list.
ListView list = (ListView) findViewById(R.id.myListView);
list.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView> adapter, View view,
final int pos, long id) {
Intent intent = new Intent(context,Finaldeal.class);
String jsonData = jsonList.get(pos);
intent.putExtra("deal", jsonData);
startActivity(intent);
}
});