So we know how to make a certain image. You just write into the xml:
android:src="@drawable/myimage"
But how do you change this source image while the program is running, i.e. inside the Java code?
I have essentially a listactivity which makes the same image appear multiple times. Now I'd like to make it so that, for each item it lists:
if(condition1)
{make image1 appear there}
else if(condition2)
{make image2 appear there}
I tried stuff like
findViewById(R.id.ImageView01).setBackgroundDrawab le(drawable/image2);
(or do I have something mixed up, what's the backgrounddrawable? Cause I didn't see any other drawable you could "set")
and I tried findViewById(R.id.ImageView01)).setVisibility(0); , figuring I could cheat and just put the two images side by side, and make the one invisible that doesn't apply.
But both these attempts just make the program crash.
Any help would be appreciated, thanks.