11

私はAndroidアプリを開発しています。

計算が行われている間、ダイアログウィンドウは数秒間フォアグラウンドにとどまるため、ユーザーがボタンを押した後、[OK] ボタンを非表示にしたいと思います。

これはコードです:

    new AlertDialog.Builder(this)
    .setMessage("This may take a while")
    .setPositiveButton("OK", new android.content.DialogInterface.OnClickListener() {                
        @Override
        public void onClick(DialogInterface dialog, int which) {
                       // hide the OK button - how?
                       // a lot of computation
        }
    })
    .show(); 

どうすればそれを達成できますか?

PS: 計算を処理するためのより高度な手法 (進行状況ダイアログ、マルチスレッドなど) には興味がありません。

ありがとう。

4

4 に答える 4

22
.setPositiveButton("OK", new android.content.DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
         ((AlertDialog)dialog).getButton(which).setVisibility(View.INVISIBLE);
         // the rest of your stuff
    }
})
于 2010-11-27T22:51:08.863 に答える
-3

ボタンの可視性を非表示に設定できます。

ok.setVisibility(View.INVISIBLE);
于 2010-11-27T13:07:04.233 に答える