Android Question B4XPages and Custom Dialog

Declan

Well-Known Member
Licensed User
Longtime User
I am trying to port this example "CustomB4XDialogTemplate" into my B4XPages app.
I receive this error:
B4XPage2 - 19: Undeclared variable 'activity' is used before it was assigned any value.

This is my code for B4XPage2:
B4X:
Sub Class_Globals
    Private Root As B4XView 'ignore
    Private xui As XUI 'ignore
    
    Private Dialog As B4XDialog
    Dim mt As MyTemplate
End Sub

'You can add more parameters here.
Public Sub Initialize As Object
    Return Me
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    'load the layout to Root
    
    Dialog.Initialize(Activity)<-----ERROR HERE
    mt.Initialize
    mt.Items.Add("View saved items")
    mt.Items.Add("Open in Safari")
    mt.Items.Add("Copy link")
    mt.Items.Add("Mark link as suspicious")
    ConfigureDialog
    
End Sub

Sub ConfigureDialog
    Dialog.ButtonsHeight = 0
    Dialog.BackgroundColor = xui.Color_White
    Dialog.OverlayColor = xui.Color_Transparent
    Dialog.BorderColor = 0xFFAEAEAE
    Dialog.BorderCornersRadius = 10dip
    Dialog.BorderWidth = 1dip
End Sub

Sub Activity_Click
    Wait For (Dialog.ShowTemplate(mt, "", "", "")) Complete (Result As Int)
    If Result = xui.DialogResponse_Positive Then
        Log(mt.Result)
    End If
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.

How do I initialize the Dialog
 
Top