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

后端 未结 7 1953
南方客
南方客 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:37

    check this https://github.com/hslls/order-alert-buttons

    dependencies {
        compile 'com.github.hslls:order-alert-buttons:1.0.0'
    }
    
    
    AlertDialogParams params = new AlertDialogParams();
    params.mTitle = "title";
    params.mMessage = "message";
    params.mPositiveText = "Ok";
    params.mNegativeText = "Cancel";
    params.mCancelable = true;
    params.mAlign = BUTTON_ALIGN.POSITIVE_BUTTON_LEFT;  // fix button position
    params.mClickListener = new AlertDialogClickListener() {
        @Override
        public void onPositiveClicked() {
    
        }
    
        @Override
        public void onNegativeClicked() {
    
        }
    };
    
    AlertDialog dialog = AlertDialogBuilder.createAlertDialog(this, params);
    

提交回复
热议问题