Scope:
– using overriden ArrayAdapter;
– using selector;
– using isEnabled for disabling items.
Aim:
– disable some list items and load disabled state view via selector.
Problem:
– everything works (custom view, selector for unfocused, focuesd and pressed states) but disabled items don’t use selector for disabled state.
Investigating: when I use isEnabled for disabling some items in listview Hierarchy Viewer shows that disabled items are unfocusable, unclickable but(!) enabled.
Is it a bug or something is missing?
P.S. actually, docs say that isEnabled doesn’t do setEnabled(false) for list item, it makes it a divider(?) object.
P.P.S I also tried to use if-statement to set my View (in getView) as isEnabled(false). But it works only for focused items?
My Selector looks like:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Disabled -->
<item
android:state_enabled="false"
android:textColor="@color/greyDark"
android:drawable="@drawable/list_item_disabled" />
<!-- Pressed -->
<item
android:state_enabled="true"
android:state_pressed="true"
android:textColor="@android:color/white"
android:drawable="@drawable/list_item_pressed" />
<!-- Focused -->
<item
android:state_enabled="true"
android:state_focused="true"
android:textColor="@android:color/white"
android:drawable="@drawable/list_item_focused" />
<!-- Default -->
<item
android:state_enabled="true"
android:drawable="@drawable/list_item_unfocused" />
</selector>
Hack:
use getView to check disabled item logic and inflate view with another layout. isEnabled is still usefull.