0

I'm a total beginner to Java and I'm having what feels like a really simple problem, but I can't find a solution anywhere on the internet. I'm not sure if I'm just being dumb or something.

I have an activity, in the .xml;

 <ImageView
 android:id="@+id/imageView1"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:src= XXX />

Where I have the XXX I would like to be a variable. I've tried replacing it with "${Head}" as well as Head, with the following in the .java code for the same activity;

String Head = "@drawable/headsquare";

When I try to build with "${Head}", I get an error message saying Error:(26, 20) String types not allowed (at 'src' with value '${head}').

I eventually want multiple images that are variables that I can easily change depending on other things going on elsewhere in the program.

Thanks for any help.

  • Possible duplicate of [How do I set an ImageViews source programmatically in Android?](http://stackoverflow.com/questions/5294031/how-do-i-set-an-imageviews-source-programmatically-in-android) – jagapathi May 14 '17 at 13:59
  • Refer this http://stackoverflow.com/questions/31405857/android-combine-multiple-images-into-one-imageview – Vishal Senjaliya May 14 '17 at 14:38

0 Answers0