Android Code Snippet [B4X] [XUI] Change the OK-Cancel buttons order in B4XDialog

skrjabin

Active Member
Licensed User
OK-Cancel or Cancel-OK, what to prefer in dialogs? It depends on the guidelines and it should be flexible. That's why I did this small modification in the B4XDialog library and I hope, that something like that could be integrated in the official one.

Add in Class_Globals
B4X:
Public ButtonsYesToRight As Boolean
Modify the Sub ShowCustom (Content As B4XView, Yes As Object, No As Object, Cancel As Object) As ResumableSub
B4X:
If ButtonsYesToRight Then
     CreateButton(Yes, xui.DialogResponse_Positive)
     CreateButton(No, xui.DialogResponse_Negative)
     CreateButton(Cancel, xui.DialogResponse_Cancel)
Else
     CreateButton(Cancel, xui.DialogResponse_Cancel)
     CreateButton(No, xui.DialogResponse_Negative)
     CreateButton(Yes, xui.DialogResponse_Positive)
End If
And you use it like
B4X:
Dim Dialog As B4XDialog
Dialog.Initialize (Base)
Dialog.Title = "XUI Views"
Dialog.ButtonsYesToRight = True
 

skrjabin

Active Member
Licensed User
From now (version 1.88) you can do it in the original XUI Views with the ButtonsOrder.
B4X:
Dialog.ButtonsOrder = Array As Int(XUI.DialogResponse_Negative, XUI.DialogResponse_Cancel, XUI.DialogResponse_Positive)
 
Top