Android Question Dialogs library 2017 - ime.hidekeybord problem

FrankDev

Active Member
Licensed User
Longtime User
hello

I
use the Dialog 2017 lib with a own layout

>Wait For (sf) Dialog_Ready (pnl As Panel)
>pnl.LoadLayout("test") .....

this layout has an input field.
when I click this the keyboard appears.
(ok)

if I press a button now e.g. Cancel
and try to close the keyboard, it doesn't work.

Wait For (sf) Dialog_Result(res As Int)
If res = DialogResponse.POSITIVE Then
IME.HideKeyboard
...

I put a sleep(100) in front of the IME.HideKeyboard
it works.

I'm sure there's a better solution than with sleep

regards Frank
 

FrankDev

Active Member
Licensed User
Longtime User
it is about the following example as described in #1.
https://www.b4x.com/android/forum/t...-2017-custom-dialogs-and-async-methods.80204/

Dialog with multiple text input fields.
(without spinner)
clicking on the text field opens the keyboard.
As far as ok
click on one of the buttons (eg. Cancel or ok)
the following is triggered.

B4X:
Wait For (sf) Dialog_Result(Result As Int)
If Result = DialogResponse.POSITIVE Then
     IME.HideKeyboard
     'do something
End If

If the dialogue disappears, I also want the
Hide keyboard. But that's not the way it works.

with the above code this does not work

when I insert a sleep(100) it works

B4X:
Wait For (sf) Dialog_Result(Result As Int)
If Result = DialogResponse.POSITIVE Then
     sleep(100)
     IME.HideKeyboard
     'do something
End If




but the sleep(100) is certainly not really good​
 
Last edited:
Upvote 0

Emme Developer

Well-Known Member
Licensed User
Longtime User
The same problem happened to me today. I solved this issue in this way

B4X:
Wait For Dialog_Result (Result As Int)
    txt.Enabled = False
    txt.Enabled = True
    If Result = DialogResponse.POSITIVE then
                'what you need
        End If
    Sleep(0)
    Dim ph As Phone
    ph.HideKeyboard(Activity)

I figured out that enabling and disabling the EditText will close the keyboard when you click on button (without these for me doesn't work)
 
Upvote 0

FrankDev

Active Member
Licensed User
Longtime User
B4X:
If res = DialogResponse.POSITIVE Then
    '  Sleep(100)
    '  IME.HideKeyboard
     dlgTb.Enabled = False
  
 else if res = DialogResponse.CANCEL Then

the enable = false worked well for me
 
Upvote 0
Top