I’m attempting to have a button that mutes sound in app which now works. My new problem is that i want the image to change within my IF statement.
Button code from layout:
<Button
android:id="@+id/mute"
android:background="@drawable/sound"
android:layout_width="52dp"
android:layout_height="52dp"
android:layout_gravity="right"
/>
Here is my code for IF/mute sound code:
if (cmute == false){
Editor editor = getPrefs.edit();
editor.putBoolean("mute", true);
editor.commit();
Editor editor2 = getPrefs.edit();
editor.putBoolean("notice", true);
editor.commit();
}
if (cmute == true){
Editor editor = getPrefs.edit();
editor.putBoolean("mute", false);
editor.commit();
Editor editor2 = getPrefs.edit();
editor.putBoolean("notice", false);
editor.commit();
}
I need to add code to each IF, one to display sound on (soundon.png)button background and one to display the sound off (soundoff.png) background button image. (button ID id’mute’)
Many Thanks. =]
You can use setBackgroundResource to change the background.