【发布时间】:2013-12-03 23:26:27
【问题描述】:
我有一个在 kitkat 之前工作的进度对话框,现在它不显示对话框。 如果我在对话框关闭之前进行调试并在后执行中停止程序,则会显示对话框,这意味着代码工作得太快而无法显示对话框,但这不是真的,在 dailog 关闭后需要很长时间显示网格视图?
另一个奇怪的事情,当它确实工作时,它显示了对话框,但圆圈没有转动或动画。
感谢收到任何cmets
private class LoadPhoto extends AsyncTask<String, Void, MyPhoneImagesAdapter> {
@Override
protected void onPreExecute() {
super.onPreExecute();
// initialize the dialog
String searchingString = getResources().getString(R.string.searchingString);
String searchMsgString = getResources().getString(R.string.searchMsgString);
m_dialog.setTitle("Searching...");
m_dialog.setMessage("Please wait while loading client photos...");
m_dialog.setIndeterminate(true);
m_dialog.setCancelable(true);
m_dialog.show();
}
@Override
protected MyPhoneImagesAdapter doInBackground(String... params) {
// TODO Auto-generated method stub
// Execution code
// Note we can call a method in the main class but we are running it in
// the asynchronous thread
getPhotos();
return getPhotos();
}
@Override
protected void onPostExecute(MyPhoneImagesAdapter result) {
super.onPostExecute(result);
// Note we can update the UI from the post execute method only note we pass the adapter which
// we created in the do in background
GridView grid = (GridView) getView().findViewById(R.id.photoGrid);
grid.setAdapter(result);
// See: ImageAdapter.java
grid.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
String tst = "Pick";
String sel = path+"/"+clientPhotos[position];
listener.onImageSelected(sel);
}
});
m_dialog.dismiss();
}
【问题讨论】:
-
进度对话框在哪里初始化?
-
请确保您的 OnPreExecute 正在被调用,您可以通过敬酒来验证这一点