#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region
#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
End Sub
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim xui As XUI
    Dim dlg As B4XDialog2
    Dim dlg2 As B4XDialog2
    Dim Base As B4XView
    Private Button1 As Button
    Private btnInsideDlg1 As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("main")
    Base = Activity
    dlg.Initialize(Base)
    dlg2.Initialize(Base)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
    If KeyCode = KeyCodes.KEYCODE_BACK And dlg.Close(xui.DialogResponse_Cancel) Then Return True
    Return False
End Sub
Sub Button1_Click
    Dim pnl As B4XView = xui.CreatePanel("")
    pnl.SetLayoutAnimated(0,0,0,350dip,250dip)
    pnl.LoadLayout("dlg1")
    dlg.Title = "Dialog 1"
    Dim rs As ResumableSub = dlg.ShowCustom(pnl,"Yes","No","")
    Wait For (rs) Complete(Result As Int)
    Log(Result)
End Sub
Sub btnInsideDlg1_Click
    Dim pnl As B4XView = xui.CreatePanel("")
    pnl.SetLayoutAnimated(0,0,0,150dip,150dip)
    pnl.LoadLayout("dlg2")
    dlg2.Title = "Dialog 2"
    dlg2.ShowOnTop = True 'This make the new dialog to show on top of already shown dialog
    Dim rs As ResumableSub = dlg2.ShowCustom(pnl,"Eny","Tsia","")
    Wait For (rs) Complete(Result As Int)
    Log(Result)
End Sub