2011-04-27 78 views
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(); 

當結果出現在數組列表中時,即數值仍然是微調框仍然是空的?notifyDataSetChanged不工作?

回答

5

notifyDataSetChanged()需要從一個UI線程調用。嘗試使用AsyncTask

+2

太糟糕了,這在文檔中沒有提到。 – greg7gkb 2012-08-22 19:16:44

相關問題