Android change button background image with java?
<p>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.</p>

<p>Button code from layout:</p>

<pre><code>&lt;Button
            android:id="@+id/mute"
            android:background="@drawable/sound"
            android:layout_width="52dp"
            android:layout_height="52dp"
            android:layout_gravity="right"


     /&gt;
</code></pre>

<p>Here is my code for IF/mute sound code:</p>

<pre><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();
                                    }
</code></pre>

<p>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')</p>

<p>Many Thanks. =]</p>
