Why I want to do this is another discussion entirely, but I need to figure out the best way to make all my alert dialogs have the positive button on the right side. Note that i
I've created a solution to force order of buttons for any Android version on any device.
The idea is that we can get list of buttons of dialog in order they appear on screen and set text and actions in order we want. It guarantees that we would have same order on any device.
Please check my GitHub repository
Here is example of creating and showing dialog:
new FixedOrderDialogFragment.Builder()
.setLeftButtonText(R.string.left)
.setCenterButtonText(R.string.center)
.setRightButtonText(R.string.right)
.setDefaultButton(FixedOrderDialogFragment.BUTTON_RIGHT)
.setMessage(R.string.message)
.setTitle(R.string.app_name)
.create()
.show(getSupportFragmentManager(), "DEMO");
Please note that owner Activity should implement FixedOrderDialogFragment.FixedOrderDialogListener to be able restore dialog state on Activity re-creation.