0

1 つの画像を持つ 1 つのカスタム アラート ダイアログを作成しています。私が直面している問題は次のとおりです。

1) 画面が小さいデバイスの場合、この警告ダイアログ ボックスが大きすぎるように見えます。aletdialog ボタンが画面の外に出ています (正と負のボタン)。

2) アラート ダイアログが 2 回描画されます。つまり、上下に 2 つの警告ダイアログがあり、両方を閉じるには、正のボタンを 2 回クリックする必要があります。

alertdialog のコードは次のとおりです。

AlertDialog.Builder alertdialog = new AlertDialog.Builder(
                    Activity.this);
            alertdialog.setTitle("Title ");
            alertdialog.setMessage("The MEssage ");


            LayoutInflater layoutinf= LayoutInflater.from(Activity.this);
            final View view = layoutinf.inflate(R.layout.layoutfile, null);
            alertdialog.setView(view);
            alertdialog.setPositiveButton("Button1",
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog,
                                int which) {
                            //do something 
                        }
                    });
    alertdialog.show();

どんな指針も役に立ちます。

ありがとう

4

1 に答える 1

1

2番目の質問のアラートダイアログは次のようになります。

AlertDialog.Builder alertdialog= new AlertDialog.Builder(this);
alertdialog.setTitle("Title");
alertdialog.setPositiveButton("OK", okListener); 
alertdialog.setNegativeButton("Cancel", cancelListener); 
AlertDialog alertdialogDlg = alertdialog.create(); 
alertdialogDlg.show(); 

 public DialogInterface.OnClickListener okListener = new      
 DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            //do something
        }
    };
于 2013-03-23T17:51:16.270 に答える