Skip to content Skip to sidebar Skip to footer

How To Pass Json Data From Listview To New Activity

I have created a ListView that is populated with JSON data, and I have included OnItemClickListener to open a new Activity through Intent. What I'm trying to do is to make that new

Solution 1:

You can send an object as a parameter to another activity if the object implements Parcelable:

A typical implementation of Parcelable here

Then, to send like parameter, something like this:

Intent intent = newIntent(this, DetailMovieActivity.class);
intent.putExtra("key", movie);//Your object that implements ParcelablestartActivity(intent);

And in the other activity:

Bundlearguments=newBundle();
Moviemovie= getIntent().getParcelableExtra("key"));//Receive object

Good luck!

Solution 2:

If you do not like the Parcelable approach or do not know how to do it you can simply pass the JSONObject as a String like described here.

The only thing you have to worry about is retrieving the right JSONObject inside your OnItemClickListener.

Post a Comment for "How To Pass Json Data From Listview To New Activity"