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.
Asked
Active
Viewed 333 times
0
-
1Does 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 Answers
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?

Jyotish Biswas
- 674
- 5
- 11