How do I clear ListView selection?

前端 未结 4 549
名媛妹妹
名媛妹妹 2020-12-01 19:15

TL;DR: You choose an option from (a) my listview. Then, you change your mind and type something in (b) my edit text. How do I clear your list

4条回答
  •  醉梦人生
    2020-12-01 19:40

    Just call clear when you make the request for the second data set:

        arrayAdapter!!.clear()
    

    You load your first data set
    The user select one elements,
    This action highlight your item
    For any reason you launch the reload of your data set (because edittext's value changed),
    at this moment call, clear() on your adapter.
    Then you retrieved your dataset, you send it to the arrayAdapter and No one is selected .
    This is because when you clear, it also clear the selected flag

提交回复
热议问题