It is necessary to transfer a picture from the list to the following activity, it does not transmit via intent.

List Activation:

public class Spisok extends AppCompatActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //Лист для продуктов ListView listV = (ListView) findViewById(R.id.productsList); CustomArrayAdapter adapter; adapter = new CustomArrayAdapter(this); listV.setAdapter(adapter); listV.setOnItemClickListener(new ItemList()); } class ItemList implements AdapterView.OnItemClickListener{ @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { ViewGroup vg = (ViewGroup) view; TextView tv = (TextView) vg.findViewById(R.id.productListName); TextView text = (TextView) vg.findViewById(R.id.productListText); ImageView img = (ImageView) vg.findViewById(R.id.thumbnailImage); //Картинка которую нужно передать Toast.makeText(Spisok.this, tv.getText().toString(), Toast.LENGTH_LONG).show(); Intent intent = new Intent(Spisok.this, ActivityTwo.class); intent.putExtra("text", text.getText().toString()); intent.putExtra("fname", tv.getText().toString()); startActivity(intent); } } } 

Activate where you need to send:

 public class ActivityTwo extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.products_sign); TextView productName1 = (TextView) findViewById(R.id.productListName1); TextView productText = (TextView) findViewById(R.id.productListText1); ImageView image = (ImageView) findViewById(R.id.thumbnailImage1); Intent intent = getIntent(); String fName = intent.getStringExtra("fname"); String text1 = intent.getStringExtra("text"); productName1.setText(fName); productText.setText(text1); } } 

1 answer 1

Convert the image to Bitmap and ByteArrayOutputStream then send via Intent the following code example:

 // Первое активити Intent intent = new Intent(Spisok.this, ActivityTwo.class); Bitmap bitmam; ByteArrayOutputStream bs = new ByteArrayOutputStream(); bitmam.compress(Bitmap.CompressFormat.PNG, 50, bs); i.putExtra("byteArray", bs.toByteArray()); startActivity(i); // Второе активити if(getIntent().hasExtra("byteArray")) { ImageView imageView = new ImageView(this); Bitmap bitmam = BitmapFactory.decodeByteArray( getIntent().getByteArrayExtra("byteArray"),0,getIntent().getByteArrayExtra("byteArray").length); imageView.setImageBitmap(bitmam); 
  • Thanks for the help converted using the Bitmap line bitmap = ((BitmapDrawable) img.getDrawable ()). GetBitmap (); - Crozen93