• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps ImageButton, onkeydown and picture?

Grendizer

Newbie
Hi all,

I have a Dialpad in which there are multiple buttons. Whenever a button is clicked a sounds plays and the background of the imagebutton is changed.
For this I'm using
PHP:
ImageButton zero = (ImageButton) findViewById(R.id.btnZero);
        zero.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                playSound(R.raw.mamacita_zero);
            }
        });
And the XML for the button is as follows:
PHP:
<?xml version="1.0" encoding="utf-8"?>
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
 
     <item 
         android:state_pressed="true"         
        android:drawable="@drawable/green0" /> <!-- pressed -->        
        
     <item 
         android:drawable="@drawable/blue0" /> <!-- default -->
     
 </selector>
I also have an onKeyDown(...) method for playing the sound, but I'm not able to get the imagebutton to switch background on the click...So my question is how to change the imagebutton's background when the onkeydown method is used?
Any tips would be appreciated...
 
Back
Top Bottom