Android Code Snippet [B4X] [B4XPages] Nested B4XDialogs

B4A project is attached.

By default, when a B4XDialog is shown it will close other visible dialogs. This is prevented with this line:
B4X:
Dim rs As Object = MainDialog.ShowCustom(CustomPanel, "Ok", "", "")
MainDialog.Base.Parent.Tag = "" 'this will prevent the dialog from closing when the second dialog appears.
Wait For (rs) Complete (Result As Int)

The other interesting thing is how to handle the back key:
B4X:
Sub B4XPage_CloseRequest As ResumableSub
    For Each d As B4XDialog In Array(SecondDialog, MainDialog) 'order is important. Should start from the nested dialog.
        If d.Visible Then
            d.Close(xui.DialogResponse_Cancel)
            Return False 'don't close the page
        End If
    Next
    Return True
End Sub
 

Attachments

  • NestedB4XDialogs.zip
    10.9 KB · Views: 851

Mostez

Well-Known Member
Licensed User
Longtime User
I tried your example, but I got this error message:

B4A Version: 9.90 BETA #2
Java Version: 8
Parsing code. (0.08s)
Building folders structure. (0.04s)
Compiling code. Error
Error compiling program.
Error description: Unknown member: activity_actionbarhomeclick
Error occurred on line: 32
B4XPages.Delegate.Activity_ActionBarHomeClick
Word: activity_actionbarhomeclick
 
Top