显示后如何更改AlertDialog.Builder的标题?

div*_*duz 4 android android-webview android-alertdialog

我想在我的应用程序中实现一个应用程序浏览器.为了实现我在AlertDialog.Builder对象中使用WebView并显示它.

final AlertDialog.Builder alert = new AlertDialog.Builder(context);
Run Code Online (Sandbox Code Playgroud)

现在我遇到了问题,我希望AlertDialog.Builder的标题显示加载页面的进度,所以我覆盖了onProgressChanged函数并尝试重置标题,如下所示:

wv.setWebChromeClient(new WebChromeClient() {
    public void onProgressChanged(WebView view, int progress) {
        alert.setTitle("Loading..." + progress + "%");
    tv.setText("Loading..." + progress + "%");
    view.setVisibility(View.GONE);
    if (progress == 100) {
        alert.setTitle(title);// THIS DOES NOT HAVE ANY EFFECT
        tv.setVisibility(View.GONE);//THIS IS "LOADING..." string, That I have written as make shift for the time being
        view.setVisibility(View.VISIBLE);//This displays the WebView when it if loaded.
    }
}
});
Run Code Online (Sandbox Code Playgroud)

我希望AlertDialog.Builder标题动态更改.

小智 5

构建器仅用于第一次创建AlertDialog实例.在显示之前使用AlertDialog.create获取对话框实例的句柄,然后可以在其上设置标题.