<ImageView
android:id="@+id/avatar_repo_list"
android:layout_width="48dp"
android:layout_height="48dp"
android:src="?attr/avatar_repo_icon"
tools:ignore="ContentDescription" />
like this, but from the class
<ImageView
android:id="@+id/avatar_repo_list"
android:layout_width="48dp"
android:layout_height="48dp"
android:src="?attr/avatar_repo_icon"
tools:ignore="ContentDescription" />
like this, but from the class
In you activity
, Get the reference of this image view
using findViewById()
and then you can use this reference to call the methods. These methods then set the attribute value of your image view
. Here is the exemplary snippet.
ImageView img=(ImageView) findViewById(R.id.avatar_repo_list);
//Suppose I need to set the Drawable programatically
img.setImageDrawable(R.drawable.my_image);
First of all get the reference of your image-view in your Activity class through "ID", and then add attr value like this: