【发布时间】:2011-07-19 09:15:39
【问题描述】:
范围: - 使用覆盖的 ArrayAdapter; - 使用选择器; - 使用 isEnabled 禁用项目。
目标: - 禁用一些列表项并通过选择器加载禁用状态视图。
问题: - 一切正常(自定义视图、未聚焦、聚焦和按下状态的选择器),但禁用的项目不使用禁用状态的选择器。
正在调查:当我使用 isEnabled 禁用列表视图中的某些项目时,层次结构查看器显示禁用的项目无法聚焦、无法点击但(!)已启用。
这是一个错误还是缺少什么?
附:实际上,文档说 isEnabled 不会对列表项执行 setEnabled(false) ,它使它成为一个 divider(?) 对象。 P.P.S 我还尝试使用 if 语句将我的视图(在 getView 中)设置为 isEnabled(false)。但它只适用于重点项目?
我的选择器看起来像:
<?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>
【问题讨论】:
标签: android xml listview android-arrayadapter