0

I am developing an application and it is having multiple image views and multiple images. I want to check, which image is set on an image view, and i want to put that same image in an another image view. The application is having multiple images. How can i implement this programatically, specifically JAVA.

ADM
  • 20,406
  • 11
  • 52
  • 83
  • 1
    Does this answer your question? [How to check which current image resource is attached to ImageView in android xml?](https://stackoverflow.com/questions/23357706/how-to-check-which-current-image-resource-is-attached-to-imageview-in-android-xm) – MrX Aug 14 '20 at 06:28

1 Answers1

0

You can add tag to ImageView,

Set a tag either in xml or dynamically In xml:

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/imageview" 
    android:background="@drawable/drawable_name"
    android:tag="drawable_name"/>

Dynamically,

ImageView imageView=(ImageView)findViewById(R.id.imageview);
imageView.setTag("bg");

Use imageView.getTag() to retrieve image information.

String backgroundImageName = String.valueOf(imageView.getTag()); 

you can set tag when you change your drawable and get it by this method

You can see these question to get some other idea

How to check which current image resource is attached to ImageView in android xml?

How to check which image is linked to ImageView in android?

Jyotish Biswas
  • 674
  • 5
  • 11