Unclickable menu item that is not greyed out in Android
1 answer
To achieve this, you must specify your style for the element ListView
with selector
:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:state_enabled="true"
android:drawable="@drawable/btn_default_normal" />
<item android:state_window_focused="false" android:state_enabled="false"
android:drawable="@drawable/btn_default_normal" />
<item android:state_pressed="true"
android:drawable="@drawable/btn_default_pressed" />
<item android:state_focused="true" android:state_enabled="true"
android:drawable="@drawable/btn_default_selected" />
<item android:state_enabled="true"
android:drawable="@drawable/btn_default_normal" />
<item android:state_focused="true"
android:drawable="@drawable/btn_default_normal_disable_focused" />
<item
android:drawable="@drawable/btn_default_normal" />
</selector>
This is the code taken from the standard xml button. I changed it so that in state android:state_enabled="false"
it still uses the normal background.
You can change it to whatever you want your object to look like.
Place it in an xml file called for example my_item.xml
put it in a drawing directory and then in the xml where you create your element set its background background="@drawable/my_item"
.
+2
source to share