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 に答える