-1

how can I set src attribute (line 7) dynamically in android studio,I tried to change the backgroundResource but is not the same

XML file

<ImageView
    android:onClick="next2"
    android:layout_margin="10dp"
    android:id="@+id/img3"
    android:layout_width="60dp"
    android:layout_height="60dp"
    android:background="@drawable/img3"
    android:src="#9d070976"
    android:layout_toEndOf="@+id/img2" />

Java code

a.setBackgroundResource(R.color.mycolor);
WarrenFaith
  • 57,492
  • 25
  • 134
  • 150
omaro head
  • 11
  • 6

1 Answers1

2

Depending on what form your image is in, use:

If your replacement image is in the form of a URL or Uri that you need to load, use an image-loading library like Picasso or Glide. They can load the image in the background and fill in the ImageView once the image is ready to be displayed.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491