我有一個奇怪的問題,正在創建一個對話框,並呼籲「秀()」,但不是在我的活動可見......ProgressDialog沒有顯示出來,儘管顯示()被調用
的東西是它通過調用「作秀」,我已經看到了它在調試器,但沒有...
這裏是代碼:
protected void initializeSpinners() {
spnPlayLists = (Spinner) findViewById(R.id.spnLists);
spnProviders = (Spinner) findViewById(R.id.spnProvider);
spnProviders.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> _spinner, View _parent,
int _pos, long _id) {
if (_spinner == spnProviders) {
String[] playListsId = core.getAllPlayListsFrom(_pos);
int items = playListsId.length;
**showProgressDialog(items);**
String[] playListsNames = new String[items];
String[] playListsThumbs = new String[items];
playLists = new PlayList[items];
for (int i = 0; i < items; i++) {
String id = playListsId[i];
PlayList playList = core.getPlayList(id, true);
playLists[i] = playList;
playListsNames[i] = playList.title;
playListsThumbs[i] = playList.thumb;
handle.sendEmptyMessage(i);
}
loadPlayLists(playListsNames, playListsThumbs);
myPd_bar.dismiss();
}
}
@Override
public void onNothingSelected(AdapterView<?> _arg0) {
}
});
ProvidersArrayAdapter providersAdapter = new ProvidersArrayAdapter(this);
spnProviders.setAdapter(providersAdapter);
}
和函數調用:
private void showProgressDialog(int _items) {
handle = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
myPd_bar.setProgress(msg.what + 1);
}
};
myPd_bar = new ProgressDialog(Intro.this);
myPd_bar.setMessage("Loading....");
myPd_bar.setTitle("Please Wait..");
myPd_bar.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
myPd_bar.setProgress(0);
myPd_bar.setMax(_items);
**myPd_bar.show();**
}
我在做什麼壞事?
我不知道太多關於ProgressDialog但也許嘗試'myPd_bar.create ().show();'。不知道在這裏是否需要'.create()'... – TronicZomB 2013-04-23 20:14:14
甚至不允許! :)無論如何感謝 – Nhano 2013-04-24 17:25:08
好吧,我也發現這個早上''.show()'將創建對話框並顯示在一個!所以在這個例子中'.create()'是沒有必要的。我曾經使用過的對話框的方式我從來沒有遇到過,僅僅使用.show()沒有.create會更好,所以我從來不知道這一點。 – TronicZomB 2013-04-24 17:29:40