dynamically adding a value to a statically created spinner
I have a spinner that is c开发者_如何学JAVAreated using the resource file statically. now i want to dynamically add a value to the spinner. Is this possible?
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.
精彩评论