0

I'm beginning in mobile application development and I want to know how to send an item from a ListView to appear in another activity; Then I can show more information about each item.

I managed to display the title and description with the following code:

MainActivity

TextView txt = (TextView)findViewById(R.id.textView1);
Intent intent = new Intent(MainActivity.this, SecondActivity.class);
intent.putExtra("title", txt.getText()); 
startActivity(intent);

SecondActivity

TextView txt = (TextView)findViewById(R.id.show_textView1);

Bundle b = this.getIntent().getExtras();
String val = b.getString("name");
txt.setText(val);

but how do I set putExtra for an image to display in the next Activity ?

P.S. everything is working fine, the xml file where the item details will be shown is set.

rdrey
  • 9,379
  • 4
  • 40
  • 52
zouzou b lebiane
  • 175
  • 2
  • 4
  • 12
  • Check these: [link](http://stackoverflow.com/questions/12210156/passing-the-image-in-putextra-in-android) | [link](http://stackoverflow.com/questions/4352172/how-do-you-pass-images-bitmaps-between-android-activities-using-bundles) – Mohi Nov 19 '14 at 17:52
  • Post your layouts where image is and should travel to. – Simas Nov 19 '14 at 17:52
  • image is dynamic or static in application. – Krunal Indrodiya Nov 19 '14 at 17:57

2 Answers2

1

What is the source of the image?

If a file, pass in the String to the file location.

bundle.putString("file-loc",fileLocation);

If a resource, pass in the resource.

bundle.putInt("resource-id",resid);

If it's just a bitmap, you can actually pass it directly, as a Parcelable.

bundle.putParcelable("bitmap",bitmap);
PearsonArtPhoto
  • 38,970
  • 17
  • 111
  • 142
0

You can send the ImageView's id (R.drawable.your_image) and then fetch it and show it in the ImageView of other activity

Sarthak Mittal
  • 5,794
  • 2
  • 24
  • 44