简体   繁体   中英

How to compare a drawable inside an imageView with another drawable?

I have a drawable inside an imageView and I need to know which drawable is to modify it.

    <ImageView
    android:id="@+id/dice_image1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:src="@drawable/empty_dice"
    tools:src="@drawable/dice_1"/>

I already tried with constant state but it's deprecated and works sometimes

I found a solution. I put a tag inside each imageview to be able to track what image was inside. Every time I changed the image I updated the tag number.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM