安卓:对话框问题 [英] Android:dialog box issue
问题描述
我用的是进度对话框,第一次当我加载Web视图,并创建的OnCreate对象
I use the Progress Dialog ,first time when I load the web view and create the object in OnCreate
progressBar = new ProgressDialog(this);
progressBar.setCancelable(true);
progressBar.setMessage("Loading...");
progressBar.setOnCancelListener(new OnCancelListener() {
public void onCancel(DialogInterface arg0) {
if (progressBar.isShowing())
progressBar.dismiss();
finish();
}
});
progressBar.show();
和驳回onPageFinished
and dismiss it onPageFinished
public void onPageFinished(WebView view, String url) {
Log.i("TEST", "Finished loading URL: " + url);
if (progressBar.isShowing()) {
progressBar.dismiss();
}
}
然后我从加载菜单另一个URL然后我写onPageStarted的code
then I load another url from menu then I write the code in onPageStarted
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
if(progressBar.isShowing()){}
else
//progressBar.
progressBar.show();
super.onPageStarted(view, url, favicon);
}
在第二次对话圈没有运行
,所有的一切工作正常。
您可以在阿洛斯ApiDemos查看同样的问题。
请安装在设备Apidemos应用程序然后去查看 - >进步酒吧,>对话框 - >点击显示Intermediat
然后使用辞退回button.Now在同一按钮添加点击,圆动画将工作
on second time the circle in Dialog is not running, all everything works fine. you can view same problem in ApiDemos alos. please install Apidemos application in device then go to view->progress bar->dialog->click on "show Intermediat" then dismiss using back button.Now add click on same button, the circle animation will working
在此先感谢。
推荐答案
喜
因为当我们关闭该对话框活动店面它值这么第二次调用它加载的对话框相同状态,因此需要实现上prepareDialog重设新的价值和使用removeDialog(INT)这是问题与活动之前的表现。请检查出来的ProgressBar不重置为0,在打开第二遍的时候。
code此处
@Override
protected void onPrepareDialog(int id, Dialog dialog) {
switch (id) {
case DIALOG_WEBVIEW:
progressBar.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressBar.setMessage("Loading...");
progressBar.setCancelable(true);
//mProgressDialog.show();
return;
default:
return ;
}
//super.onPrepareDialog(id, dialog);
}
有关onCreateDialog
for onCreateDialog
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_WEBVIEW:
progressBar = new ProgressDialog(this);
progressBar.show();
return progressBar;
default:
return null;
}
}
最后显示,解雇并删除这样的
lastly to show,dismiss and remove like this
removeDialog(DIALOG);
showDialog(DIALOG);
dismissDialog(DIALOG);
这篇关于安卓:对话框问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!