0

カスタム DialogFragment (サポート ライブラリ) があります。レイアウトを @color/GhostWhite に設定しましたが、問題は、正/負のボタンを同じ色に設定する方法が見つからないことです。

これは私がボタンを設定する方法です:

        builder.setView(view)
    // Add action buttons
           .setPositiveButton("Shout!", new DialogInterface.OnClickListener() {
               @Override
               public void onClick(DialogInterface dialog, int id) {
                   //publishStory(/*shoutText.getText().toString()"woww");
                   mListener.onDialogPositiveClick(WagDialogFragment.this);
               }
           })
           .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
               public void onClick(DialogInterface dialog, int id) {
               }
           });  

    return builder.create();
4

2 に答える 2

5

次のように、両方のボタンの色を変更するためのパラメーターを使用してgetButton呼び出すDialogInterface.BUTTON_POSITIVEことができます。DialogInterface.BUTTON_NEGATIVE

Button okButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
// set OK button color here
okButton.setBackgroundColor(R.color.GhostWhite);

Button noButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE);
// set NO button color here
noButton.setBackgroundColor(R.color.GhostWhite);
于 2013-05-09T19:03:58.367 に答える