2011-02-02 68 views
2

嗨 我结合使用setAdapter数据列表视图,但是当我尝试绑定它显示零点异常安卓:ListView.setAdapter显示空例外

public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
     try { 
      listView1 = (ListView) findViewById(R.id.ListView); 

     Thread t = new Thread() { 
      public void run() { 
       listItems=getList(); 
       pHandler.post(mUpdateResults); 
      } 
      }; 
     t.start(); 
    } catch (Exception e) { 

     progress.dismiss(); 

    } 
} 
final Handler pHandler = new Handler(); 

// Create runnable for posting 
final Runnable mUpdateResults = new Runnable() { 
    public void run() { 
     updateTabData(); 
    } 
}; 
private void updateTabData() { 
    try { 


     this.post_Adapter = new PostAdapter(this, R.layout.outkrys, 
       listItems); 

     Toast.makeText(OutKrys.this, "Inside updateTab after post_adapter intial "+this.post_Adapter.items.size(), Toast.LENGTH_LONG).show(); 
    listView1.setAdapter(new PostAdapter(this, R.layout.outkrys,listItems));         
       progress.dismiss(); 
    } catch (Exception e) { 
     Toast.makeText(OutKrys.this, "Inside updateTabData "+e, Toast.LENGTH_LONG).show(); 
     progress.dismiss(); 

    } 
} 

在此this.post_Adapter.items.size ()显示计数,但是,我不能使用listView1.setAdapter(新的PostAdapter(this,R.layout.outkrys,listItems)); 请帮助... 问候奥古斯丁

回答