[英]Android display progress dialog in front of alert dialog
我的AsyncTask進度對話框出現問題。 這是場景。 我有一個帶有警報對話框的應用程序,然后檢查數據庫中的內容。 如果結果為true,則將調用AsyncTask,其中顯示進度對話框。 進度對話框顯示在警報對話框的后面。 如何在警報對話框前面顯示進度對話框?
AsyncTask:
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(ReadBibleActivity.this);
pDialog.setMessage(getResources().getString(R.string.translating_bible_version));
pDialog.setIndeterminate(true);
pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
pDialog.setCancelable(false);
pDialog.show();
}
警報對話框:
private void displayDialog() {
customDialog = new Dialog(this);
customDialog.setTitle(getResources().getString(R.string.share));
customDialog.setContentView(R.layout.dialog);
etTitle = (EditText) customDialog.findViewById(R.id.etTitle);
etDescription = (EditText) customDialog.findViewById(R.id.etDescription);
if(caller == 1) {
String userVersion = dbHelper.getUserVersion(userId);
if((userVersion != null && !userVersion.isEmpty())
&& !userVersion.equalsIgnoreCase("TLC")) {
if(ConnectionDetector.hasNetworkConnection(this)) {
scrapeTask = new ScrapeAsyncTask();
scrapeTask.execute();
} else {
Toast.makeText(this,
getResources().getString(R.string.no_internet_connection),
Toast.LENGTH_SHORT).show();
}
} else {
etTitle.setKeyListener(null);
etTitle.setText(verse);
etDescription.setText("\"" + text + "\"");
etDescription.requestFocus();
}
} else {
etTitle.setHint(text);
etTitle.requestFocus();
etDescription.setHint(text);
}
customDialog.show();
}
有任何想法嗎? 幫助將不勝感激。 謝謝!
嘗試調用customDialog.show();
在scrapeTask = new ScrapeAsyncTask();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.