我試圖讓ProgressDialog在顯示它之前加載我的列表視圖,但我得到了崩潰。會有更好的方法來實現這個嗎?ProgressDialog崩潰應用程序
編輯:更新logcat錯誤,忘記它。
List<String> internetArray = new ArrayList<String>();
private ProgressDialog p;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ListView internetList = (ListView)findViewById(R.id.list);
p = ProgressDialog.show(this, "Please wait..", "Loading list..", true);
new Thread(){
public void run(){
//do some extreme work before creating list
try {
sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
internetArray.clear();
//p.dismiss();
}
}.start();
getPermissions(this);
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, internetArray);
arrayAdapter.sort(new Comparator<String>() {
public int compare(String object1, String object2) {
return object1.compareTo(object2);
};
});
internetList.setAdapter(arrayAdapter);
}
發佈您的LogCat – Nerd 2012-07-24 22:58:24
忘了它,只是張貼。 – dythe 2012-07-24 23:01:52