Change button color in AlertDialog

后端 未结 16 2303

How can I change the color of the button(s) in an AlertDialog in Android?

16条回答
  •  独厮守ぢ
    2020-12-02 22:50

    we can change alert dialog button text colour using Style.

     AlertDialog.Builder dialog = new AlertDialog.Builder(context, R.style.yourDialog);
        dialog.setTitle(R.string.title);
        dialog.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                //code here 
            }
        });
        dialog.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                //do here 
            }
        });
    
        dialog.show();
    

    Style.xml

    
    

提交回复
热议问题