Wong Ka Chun
Member
Dear all,
I found today the visible of panel for B4XDialog must be set manually. Otherwise, the dialog would not be shown.
I found it is an inconvenience for novice. Is it possible to automatically open the dialog on demand?
I found today the visible of panel for B4XDialog must be set manually. Otherwise, the dialog would not be shown.
panel dialog:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private xui As XUI
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.
Private btn1 As Button
Private Dialog As B4XDialog
Private pnlDialog As B4XView
Private pnlButton As B4XView
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("Layout1")
If pnlButton.IsInitialized = False Then
pnlButton = xui.CreatePanel("")
pnlButton.Color = Colors.Blue
btn1.Initialize("btn1")
btn1.TextColor = Colors.White
btn1.Text = "Dialog"
pnlButton.AddView(btn1, 10dip, 10dip, 300dip, 100dip)
Activity.AddView(pnlButton, 0, 0, Activity.Width, Activity.Height)
End If
If pnlDialog.IsInitialized = False Then
pnlDialog = xui.CreatePanel("")
pnlDialog.Color = Colors.White
pnlDialog.Visible = False '<-- must be invisible for dialog panel after initialized
Activity.AddView(pnlDialog, 0, 0, Activity.Width, Activity.Height)
End If
End Sub
Sub btn1_Click
If Dialog.IsInitialized = False Then
Dialog.Initialize(pnlDialog)
End If
pnlDialog.Visible = True '<-- must be visible if active
Dim LT As B4XListTemplate
LT.Initialize
LT.Options.AddAll(Array As String("Item 1","Item 2","Item 3"))
LT.Resize(LT.mBase.Width,LT.mBase.Height - 100)
Dialog.Title = "Choose"
Wait For(Dialog.ShowTemplate(LT,"","","Cancel")) Complete (Resp As Int)
pnlDialog.Visible = False '<-- must be invisible if inactive
Log(LT.SelectedItem)
End Sub
I found it is an inconvenience for novice. Is it possible to automatically open the dialog on demand?