Update Spinner value when activity is open?
Hii i 开发者_Python百科have a thread that runs and retrieve values for the spinnner from the server till then the spinnner is empty how can i update the values of the spinner when i get the values ..and my activity is open at that time.
ArrayList valforspinner=new ArrayList();
new Thread(new Runnable() {
public void run() {
valforspinner= GetList.List(myPrefs.getString("IP", ""));
adapter.notifyDataSetChanged();
}}).start();
spinner = (Spinner) findViewById(R.id.Spinner01);
adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, Printers);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
Call notifyDataSetChanged()
on the Adapter
used to fill the Spinner
.
精彩评论