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)); 請幫助... 問候奧古斯丁