I have a list view in an activity and when a row is selected I want to show another activity that contains an ImageView and a TextView. How can I set the image and text from the first activity? I'm guessing for the text I can use an extra with the intent.
Asked
Active
Viewed 202 times
1
-
you can use the intent also to provide the resource id of the pic you want to show – Blackbelt Aug 22 '14 at 11:36
-
you can pass the id of the resource(image) also as an extra in that intent. – Sagar D Aug 22 '14 at 11:37
-
Refer http://stackoverflow.com/questions/4352172/how-do-you-pass-images-bitmaps-between-android-activities-using-bundles – B Roh Aug 22 '14 at 11:51
2 Answers
2
intent.putExtra("data", bitmap)
intent.putExtra("your_string", strName);
You can recieve bitmap from another activity like this
Intent intent = getIntent();
Bitmap bitmap = (Bitmap) intent.getParcelableExtra("data");
It costs a lot of memory and is also slow.
If you want to pass it inbetween activities, you can store it in a file. That's more efficient.

Deniz
- 12,332
- 10
- 44
- 62
2
There are multiple ways to sending data between Activities
- you can send image
intent.putExtra("data", bitmap)
and recieve it as @deniz suggested - you can use Serializable to send data
- you can create Parcelable and send it to next Activity
- create a static Bitmap and get it in another Activity but it is not a good approach and against OOP

Zar E Ahmer
- 33,936
- 20
- 234
- 300