Android Question why it does not close the virtual keyboard with the IME or phone library

Roberto P.

Well-Known Member
Licensed User
I'm trying to close keyboard into a CustomLayoutDialog, but doesn't work.

why?


B4X:
Dim ime As IME
ime.Initialize("ime")
ime.HideKeyboard

or

Dim aphone As Phone
aphone.HideKeyboard
thank in advance
 

Computersmith64

Well-Known Member
Licensed User
I'm trying to close keyboard into a CustomLayoutDialog, but doesn't work.

why?


B4X:
Dim ime As IME
ime.Initialize("ime")
ime.HideKeyboard

or

Dim aphone As Phone
aphone.HideKeyboard
thank in advance
Try:

B4X:
Dim ime As IME
ime.Initialize("")
Sleep(50)
ime.HideKeyboard
- Colin.
 

Roberto P.

Well-Known Member
Licensed User
I doesn't work

I think that the problem is the messages of CustomLayoutDialog.
 

Computersmith64

Well-Known Member
Licensed User
Here's the code I use in one of my apps with a CustomLayoutDialog & it works fine:

B4X:
Public Sub setName
    Private cDlg As CustomLayoutDialog
    Private im As IME
   
    im.Initialize("")
    cDlg.ShowAsync(Starter.loc.Localize("My Name / Nickname"), Starter.loc.Localize("Save"), Starter.loc.Localize("Cancel"), "", LoadBitmap(File.DirAssets, "ic_person_black_24dp.png"), False)
    cDlg.SetSize(310dip, 250dip)
    Wait For Dialog_Ready(pnl As Panel)
    pnl.LoadLayout("username")
   
    txtUserName.EditText.InputType = Bit.Or(txtUserName.EditText.INPUT_TYPE_TEXT, 8192)
    txtUserName.EditText.Hint = Starter.loc.Localize("My Name / Nickname")
    im.ShowKeyboard(txtUserName.EditText)
    If Starter.cOpts.PlayerName <> "Not Set" Then txtUserName.Text = Starter.cOpts.PlayerName
    Wait For Dialog_Result(res As Int)
    If res = DialogResponse.POSITIVE Then
        Starter.cOpts.PlayerName = txtUserName.Text
        Starter.cOpts.Write_Options
        loadMenuItems
    End If
    Sleep(50)
    im.HideKeyboard
End Sub
- Colin.
 

Roberto P.

Well-Known Member
Licensed User
I think that the messages are locked when the CustomDialog is open.

see the image.

thank
 

Attachments

Computersmith64

Well-Known Member
Licensed User
Can you post the relevant code or a zip of your project?

- Colin.
 

Computersmith64

Well-Known Member
Licensed User
Hi Colin

see attached small project

thank you
OK - try this instead:

B4X:
Sub btnclick_Click
    Log("close button")
   
    EditText1.Enabled = False
    Sleep(50)
    EditText1.Enabled = True
   
   
End Sub
Don't forget to declare EditText1 in your Activity Sub Globals.

- Colin.
 
Top