Android AlertDialog Move PositiveButton to the right and NegativeButton on the left

后端 未结 7 1915
南方客
南方客 2021-01-07 23:11

I\'m new with android.

Currently I want to show an AlertDialog box with \'OK\' & \'Cancel\' buttons.

The default is PositiveButton: Left, Ne

相关标签:
7条回答
  • 2021-01-07 23:53

    There is no way to change the diffault setting in android But you can change the text ok to cancle set the functionally accroding this

    AlertDialog.Builder builder = new AlertDialog.Builder(SUtils.getContext());
        builder.setMessage("Confirmation?")
               .setCancelable(false)
               .setNegativeButton("OK", 
                   new DialogInterface.OnClickListener() {
                       public void onClick(DialogInterface dialog, int id) {
                                //TOdo
                            }
                       })
               .setPositiveButton("CANCEL", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                                //TOdo
                                dialog.cancel();
                            }
                        });
    
    
    dialog = builder.create();
    
    0 讨论(0)
提交回复
热议问题