How to dynamically change a pressed button background color?
<p>I'm developing a question game and I want to change the answer button pressed background color to green if the answer is correct or to red if the answer is wrong just in the moment the user press the button.</p>

<p>Actually I have a custom_button.xml which I assign to the buttons in the layout:</p>

<pre><code>        &lt;Button 
        android:id="@+id/la"
        android:width="63dp"
        android:height="65dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/la"
        android:tag="@string/la"
        android:layout_toRightOf="@+id/fa"
        **android:background="@drawable/custom_button"**
        android:layout_margin="3dp"
    /&gt;  
</code></pre>

<p>Is there a way to change the pressed background of a button just in the moment the user is pressing the button?</p>

<p>I tried using setBackgroundDrawable() inside the button OnClickListener but this change the button behaviour for the next time the user click the button, not the actual.</p>

<pre><code>bt.setBackgroundDrawable(getResources().getDrawable(R.drawable.custom_button_fail));
</code></pre>

<p>thanks in advance!</p>
