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

4
我希望在我的应用程序中实现一个应用内浏览器。为了实现这一目标,我使用了一个WebView,并将其放置在AlertDialog.Builder对象中并显示它。
final AlertDialog.Builder alert = new AlertDialog.Builder(context);

现在我遇到了一个问题,我想让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.
    }
}
});

我想让AlertDialog.Builder的标题动态更改。
1个回答

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接