I am trying to change the image in an ImageView by accessing source of image in CheckBox. Here is part of my xml code
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/myimage"
android:id="@+id/img"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableRight="@drawable/image1"
android:id="@+id/q4op1"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableRight="@drawable/images2"
android:id="@+id/q4op2"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableRight="@drawable/images"
android:id="@+id/q4op3"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableRight="@drawable/download"
android:id="@+id/q4op4"/>
I want to check whether the CheckBox is checked or not. if checked then the image in drawableRight of that CheckBox should appear in the ImageView.
Can you guide me how can i write java code for this?