Android Question B4XDialog Yes/Cancel

luke2012

Well-Known Member
Licensed User
Longtime User
Hello,
I'm new to B4XDialogs and I'm try to implement a Yes/Cancel simple dialog (without custom layout) like this:

"Do you want to do this?" "Yes" "Cancel"
If response = "yes" then
'Do this...
If response = "Cancel" then
'Do nothing...

How to do this using B4XDialog (XUI Views) ?
I trying to implement it like this:

B4X:
    DialogReg.Title = "B4XDialog Title"
    DialogReg.Show("Do you want to do this?", "Yes", "", "Cancel")

But I got this error:
B4X:
Error occurred on line: 191 (B4XDialog)
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Object.equals(java.lang.Object)' on a null object reference
    at cutethings.android.botegapp.b4xdialog$ResumableSub_ShowCustom.resume(b4xdialog.java:1254)
......

Thanks in advance for your preciuos help :)
Luca.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private Dialog As B4XDialog
End Sub

Public Sub Initialize
    
End Sub

Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    Dialog.Initialize(Root) 'or activity
    Dialog.Title = "Title"
End Sub


Sub Button1_Click
    Wait For (Dialog.Show("Do you want to do this?", "Yes", "No", "")) Complete (Result As Int)
    If Result = xui.DialogResponse_Positive Then
        Log("do it")
    End If
End Sub

Make sure to use B4A v10.0 (+).
 
Upvote 0

luke2012

Well-Known Member
Licensed User
Longtime User
B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private Dialog As B4XDialog
End Sub

Public Sub Initialize
   
End Sub

Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    Dialog.Initialize(Root) 'or activity
    Dialog.Title = "Title"
End Sub


Sub Button1_Click
    Wait For (Dialog.Show("Do you want to do this?", "Yes", "No", "")) Complete (Result As Int)
    If Result = xui.DialogResponse_Positive Then
        Log("do it")
    End If
End Sub

Make sure to use B4A v10.0 (+).

Thank you @Erel. It is what I want :)
 
Upvote 0
Top