sherry
sherry

Reputation: 1859

dynamically adding a value to a statically created spinner

I have a spinner that is created using the resource file statically. now i want to dynamically add a value to the spinner. Is this possible?

Upvotes: 1

Views: 694

Answers (1)

Ryan Wersal
Ryan Wersal

Reputation: 3228

Assuming your code looks something like step 4 in this Hello Spinner example (that is, you have a programmatic reference to your Spinner using the id from your XML layout and are using an ArrayAdapter as your data source), you should be able to call add() on your ArrayAdapter and then call notifyDataSetChanged() on it as well to have your Spinner update itself.

Upvotes: 3

Related Questions