Android: How to disable list items on list creation

后端 未结 4 878
栀梦
栀梦 2020-11-27 05:59

I\'m pretty new to Android dev and still working out a lot of things.

I\'ve got a main menu showing using the following code, but can\'t work out how to disable sele

4条回答
  •  有刺的猬
    2020-11-27 06:18

    You can disable a list item (= make it not respond to touches) by calling both

    setClickable(false)
    

    and

    setFocusable(false)
    

    in your adapter, for example.

    By default, this is not automatically reflected graphically, though.

    I am currently using that in a list whose list items are not clickable but most of which contain clickable widgets. Works well.

    This way, list items are drawn normally including the separator (see Janusz' reply to the accepted answer above).

提交回复
热议问题