I have a button selector that changes the button image when it is pressed. I have also set an image for when the button is disabled. I try and disable the button programmatically but the disabled button image is not appearing. Is my button_selector correct?
<item android:drawable="@drawable/red_btn_bg_disabled" android:state_enabled="false"/> <!-- disabled -->
<item android:drawable="@drawable/red_btn_bg_pressed" android:state_pressed="true"/> <!-- pressed -->
<item android:drawable="@drawable/red_btn_bg_pressed" android:state_focused="true"/> <!-- focused -->
<item android:drawable="@drawable/red_btn_bg"/> <!-- default -->
I am using mButton.setEnabled(false) in my code to disable the button
try this one and i uploaded one sample project for you for more help check the project
selector.xml
and use this selector in button as following
sample code link https://www.dropbox.com/s/lydkog10rkujbsa/ButtonSelector.rar