1

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.

raginggoat
  • 3,570
  • 10
  • 48
  • 108

2 Answers2

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

  1. you can send image intent.putExtra("data", bitmap) and recieve it as @deniz suggested
  2. you can use Serializable to send data
  3. you can create Parcelable and send it to next Activity
  4. 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