tags:

views:

63

answers:

1

Hi guys.

I am trying to make ImageButton for state of pressed, focused and normal. I've read introduction of ImageButton from this: http://developer.android.com/reference/android/widget/ImageButton.html

I've saved selector XML file in /res/drawable/. Also set the android:src="@drawable/my_selector".

my_selector.xml file :

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
    <item android:drawable="@drawable/btn_unfocus" /> <!-- default -->
    <item android:state_pressed="true"
          android:drawable="@drawable/btn_onpress" /> <!-- pressed -->
    <item android:state_focused="true"
          android:drawable="@drawable/btn_onfocus" /> <!-- focused -->
</selector>

I think I've done correct ImageButton. But it didn't work for me.

What is wrong here ?

Please advice.

Thanks.

+1  A: 

Can you be more specific about what isn't working?

Though I believe your default item (the one with no conditional attributes) should come last.

Christopher