3
ArrayList valforspinner=new ArrayList();

ArrayAdapter<String> adapter=null;

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


new Thread(new Runnable() {
            public void run() {         
        valforspinner= GetList.List(myPrefs.getString("IP", ""));
        adapter.notifyDataSetChanged();
            }}).start();

When the result comes in the arraylist i.e the values,still the spinner remains empty??

Harinder
  • 11,776
  • 16
  • 70
  • 126

2 Answers2

5

notifyDataSetChanged() needs to be called from a UI thread. Try to use AsyncTask.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
pgsandstrom
  • 14,361
  • 13
  • 70
  • 104
-1

may this will be helpful android:how to Reload the ArrayAdapater Class in Check/uncheck event of ListView's Chekbox?

Community
  • 1
  • 1