I am developing a card game on Android, and I want to change the ImageView image when the button is pressed to select a map, and I considered several other ideas, but all that I have is either a failure or it does not change.
cimg = new ImageView(this); nextCard.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { cimg.setImageResource(R.drawable.c2); doCard(); } });
Here is what I have for the code, and with this the image does not change XML:
<ImageView android:layout_height="wrap_content" android:layout_width="wrap_content" android:src="@drawable/icon" android:id="@+id/imageView1"></ImageView>
source share