1
<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

Pozzo Apps
  • 1,859
  • 2
  • 22
  • 32
DNS Frolov
  • 13
  • 3

2 Answers2

0

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);
Abhiroj Panwar
  • 485
  • 9
  • 19
0

First of all get the reference of your image-view in your Activity class through "ID", and then add attr value like this:

Android: how to get value of an attribute in code?

Community
  • 1
  • 1
Zohaib Hassan
  • 984
  • 2
  • 7
  • 11