Android Question Menu calling dialog problem

MartinR

Member
Licensed User
I find that if I call an input dialog from a menu item the pop-up keypad persists after entering the input and clicking OK. However, if I use a button to call the dialog the keypad disappears OK. There seems to be an issue of stability as well since I get the message that my app has stopped after repeated (perhaps a dozen or so times) use of the menu, but no such problem arises when using the button.

The code below illustrates the problem.

The actual app I am trying to develop allows the user to open a file via a menu. After successfully opening the file, getting the data, processing it and displaying the result the app almost always crashes/stops. However, if instead of the menu, I supply a button to allow the user to open the file all works fine.

Is there something extra I need to do to use menus? I would like to keep the display as free from buttons as possible so that the user can examine the information displayed.

I get no error reports via the log window indicating why the program crashes/stops.

B4A 5.80 Dialogs Library 2.92 Android 6 BLU ENERGY DIAMOND phone



B4X:
#Region  Project Attributes
    #ApplicationLabel: Dialog Menu Problem
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals

End Sub
Sub Globals
    Private Button1 As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.AddMenuItem("Menu1","mnuMenu1")
    Button1.Initialize("btnButton1")
    Activity.AddView(Button1,150dip,150dip,50dip,50dip)
End Sub
  
  

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub btnButton1_Click
    Dim id As InputDialog
    Dim ret,dummy As Short
    id.inputtype = id.INPUT_TYPE_NUMBERS
    id.Input= ""
    id.Hint="Click here to enter your number"
    id.HintColor=Colors.Red
    ret = id.Show("Dialog Message","Dialog Title","OK","Cancel","",Null)
    If ret = -1 And id.Input <> "" Then
        dummy = id.Input * 2
        Msgbox("Your number times 2 is: " & dummy,"Msgbox Title")
    End If
End Sub

Sub mnuMenu1_click
    Dim id As InputDialog
    Dim ret,dummy As Short
    id.inputtype = id.INPUT_TYPE_NUMBERS
    id.Input= ""
    id.Hint="Click here to enter your number"
    id.HintColor=Colors.Red
    ret = id.Show("Dialog Message","Dialog Title","OK","Cancel","",Null)
    If ret = -1 And id.Input <> "" Then
        dummy = id.Input * 2
        Msgbox("Your number times 2 is: " & dummy,"Msgbox Title")
    End If
End Sub
 
Last edited:
Top