selector for button not working

Posted by user1662334 on Stack Overflow See other posts from Stack Overflow or by user1662334
Published on 2012-09-11T09:04:15Z Indexed on 2012/09/11 9:38 UTC
Read the original article Hit count: 179

Filed under:

I want to change the background of the button when the button is unclickable.I have used selector for that but it is not working in the case when the button remains unclickable.

This is the selector file:

<?xml version="1.0" encoding="utf-8"?>
<selector
  xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_enabled="false"  android:drawable="@drawable/button_lightgrey" />
    <item  android:state_pressed="true" android:state_enabled="true" android:drawable="@drawable/button_blue"/> 
    <item android:state_focused="true" android:drawable="@drawable/button_darkgreen"  /> 
    <item  android:drawable="@drawable/button_lightgreen" /> 
</selector> 

This is the button where i am using this selector file:

<Button
                android:id="@+id/PrevButton"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_centerInParent="true"
                android:layout_marginLeft="5.0dip"
                android:layout_weight="1.0"
                android:background="@drawable/ibtn"
                android:onClick="onPrevButtonClick"
                android:text="Prev" />

Please help me.All other functions are working in the selector file but only the unclickable button case is not working.Thanks

© Stack Overflow or respective owner

Related posts about android