Disable listview items with selector and isEnabled()

前端 未结 2 913
无人共我
无人共我 2021-01-13 17:25

Scope: - using overriden ArrayAdapter; - using selector; - using isEnabled for disabling items.

Aim: - disable some list items and

2条回答
  •  一向
    一向 (楼主)
    2021-01-13 17:44

    The function isEnabled() in the adapter only makes item unfocusable and unclickable. You need to call view.setEnabled() at the end of adapter.getView() to make your selector functional.

    Also, for a parent view to pass enable state to its descendants, you need to specify the attribute android:duplicateParentState="true" to the child views in your xml file.

提交回复
热议问题