Android Get/Set Value to an ImageView

时间:2019-05-31 11:38:41

标签: android kotlin android-imageview android-xml

I have an ImageView as such:

<ImageView
    android:id="@+id/p4"
    android:layout_width="32dp"
    android:layout_height="32dp"
    android:layout_marginStart="8dp"
    android:layout_marginEnd="8dp"
    android:onClick="getPriority"
    android:value="P4"
    android:contentDescription="@string/ContentDescription_fromAddItemActivity_Priority4Icon"
    app:srcCompat="@drawable/ic_priority_4"/>

I want to get the value "P4" programatically. How do i do that ?

I've already tried ".getValue()" and it doesn't exists.

Please help me. Thank you.

1 个答案:

答案 0 :(得分:0)

instead of android:value="P4" You can use android:tag="P4" and then you can use getTag() and setTag() methods of it.