Android - SetImageResource does not work with id returned by getIntExtra
I want to get the selected image id from the second intent that shows a
gridView and set an ImageView with the selected image in the first intent,
So I set the id with putExtra in the second intent as below:
ImageAdapter adp = (ImageAdapter)parent.getAdapter();
Intent iBack = new Intent();
iBack.putExtra("image", adp.getItemId(position));
setResult(RESULT_OK, iBack);
finish();
and get the id with getIntExtra from the first intent:
int imgId = data.getIntExtra("image", R.drawable.img_default);
Toast.makeText(mContext, ""+imgId, Toast.LENGTH_LONG).show();
imageView1.setImageResource(imgId);
the Toast shows me the correct id (an integer id) but setImageResouce sets
nothing, and when I set the image with image url (ex.
setImageResource(R.drawable.img1)) it works fine. What's the problem?
No comments:
Post a Comment