Android Question Dialog/template after Msgbox2Async = no keyboard?


Active Member
Licensed User
With the following(example) code the first time the 'Wait For (NameDialog.ShowTemplate(Help, "OK", "", "CANCEL")) Complete (Result As Int)' line (28) is run no keyboard is shown, after that it shows.
It is shown if the 'Wait For Msgbox_Result (Result As Int)' line (9) is commented and a 'Msgbox_Result' sub used or if the 'Sleep(0)' line (19) is uncommented.

I can use the sleep(0) option but was just interested as to why it fails

    Dim newname As String = "a name"
    Msgbox2Async(newname & " exists, do you want to replace it?", "Existing Layout", _
                    "Yes", _
                    "Cancel", _
                    "No", _
                    Null, _
    Wait For Msgbox_Result (Result As Int)
    Select Case Result
        Case DialogResponse.POSITIVE
        Case DialogResponse.NEGATIVE
        Case DialogResponse.CANCEL
    End Select

    Dim NameDialog As B4XDialog
    NameDialog.Title = "Please enter a name"
    Dim Help As B4XInputTemplate
    Help.lblTitle.Text = "   Use something descriptive!"
    Help.RegexPattern = ".+" 'require at least one character
    Do While True
        Wait For (NameDialog.ShowTemplate(Help, "OK", "", "CANCEL")) Complete (Result As Int)


Licensed User
Apparently you want to show a dialog and then another after the first returns. Your whole structure looks wrong to me - remember that a Wait For is equivalent to a return so it will run into the second dialog call as you wait for the first. Also looping for a Wait For is unnecessary and wrong.

I would put each dialog into its own Resumable Sub and call and wait for them in turn from a third Sub.
Upvote 0


Active Member
Licensed User
It is only an Example to show the problem.
However the logic does work, i.e. the first 'wait for' waits and the second dialog runs only after the Msgbox2Async completes.
The looping is only to show that the keyboard appears on subsequent 'NameDialog.ShowTemplate' calls. It is only called once in the real code.
As I said I would be interested to know why it fails - so that I can avoid problems in the future.
Upvote 0