Harinder
Harinder

Reputation: 11944

Update Spinner value when activity is open?

Hii i 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);

Upvotes: 0

Views: 441

Answers (1)

Octavian Helm
Octavian Helm

Reputation: 39604

Call notifyDataSetChanged() on the Adapter used to fill the Spinner.

Upvotes: 2

Related Questions