Multiple choice list with custom view?

后端 未结 9 778
失恋的感觉
失恋的感觉 2020-12-02 09:07

I\'ve seen example com.example.android.apis.view.List11 from ApiDemos. In that example, each row takes the view android.R.simple_list_item_multiple_

9条回答
  •  栀梦
    栀梦 (楼主)
    2020-12-02 09:29

    I want to confirm that the Pritam's answer is correct. You need an onClickListener on each list's item (define it in the adapter's getView()).

    You can create a new onClickListener() for each item, or have the adapter implement onClickListener() - in this case the items must be tagged for the listener to know, which item it is operating on.

    Relying on the list onItemClickListener() - as someone advised in another thread - will not work as the CheckBox will intercept the click event so the list will not get it.

    And finally @Rahul and JVitella:

    The situation is that the CheckBox on a list item must be clickable and checkable independently from the list item itself. Therefore the solution is as I just described above.

提交回复
热议问题