How to update a spinner dynamically?

后端 未结 10 1167
北荒
北荒 2020-12-08 02:32

I\'ve been trying to update my spinner in android dynamically but nothing I try has been working.

This is the following code I\'m using to update the spinner.

10条回答
  •  死守一世寂寞
    2020-12-08 03:06

    When you have data changed in your list and when you want to update the spinner then

    Create a new object of the adapter and set that adapter to the spinner. It will work sure.

    Best of luck.

    Edit: Also you need to call notifyDataSetChanged() on the adapter.

提交回复
热议问题