Reputation: 447
How to get ImageView
src programmatically and set it in another ImageView
Drawable drawable = imageViewA....?
imageViewB.setImageDrawable(drawable);
Upvotes: 7
Views: 16036
Reputation: 69
Instead of get drawable you do...
Bitmap bitmap = ((BitmapDrawable)image.getDrawable()).getBitmap();
and set to new image
newImageView.setImageBitmap(bitmap);
Upvotes: 2
Reputation: 2623
You can use setImageResource(int)
imageView.setImageResource(R.drawable.bg_image);
Upvotes: 2
Reputation: 1457
You can do something like this:
Drawable drawable = imageViewA.getDrawable();
if(drawable != null){
imageViewB.setImageDrawable(drawable);
}
Upvotes: 8