4

我想在我的应用中实现一个应用内浏览器。为了实现这一点,我在 AlertDialog.Builder 对象中使用了 WebView 并显示了它。

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 标题动态更改。

4

1 回答 1

5

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

于 2013-11-03T18:17:40.307 回答