Android Question Why is ShowKeyboard doesn't always succes?

incendio

Well-Known Member
Licensed User
Longtime User
Hi guy,

I have a code like this :
B4X:
Sub GiftLst_ItemClick (Position As Int, Value As Object)
    QtyTxt.RequestFocus
    IME.ShowKeyboard(QtyTxt)
End Sub

GiftLst is a spinner. Those code should move the pointer to QtyTxt (EditText), and then shows virtual keyboard, but it always fail to show virtual keyboard on the first click.

The pointer moved, but no keyboard shows. If I clicked again the Spinner, it will success, pointer moved and keyboard shows.

Anybody have a hint how to fix this?

Thanks in advance.
 

hopelesscoder4598

Member
Licensed User
Longtime User
First Timer For Help

I am having the same problem. I tried using the CallSubDelayed and its not working.
I am using the Menu. The Menu pops up and I tap Test and this calls this Sub. It never
works the first time. I am using version 2.30 B4A. It will always the second time.
I tried everything.
B4X:
Sub mnuTest_click
   'this is when the menu pops up
    '2.30 version of B4A
    'Testing is a EditText
    Testing.Visible = True
    Testing.BringToFront
    CallSubDelayed(Me,"SetKeyboard_Two")
    'IME.ShowKeyboard (Testing)
End Sub
 
Sub SetKeyboard_Two
    IME.ShowKeyboard(Testing)
End Sub
EditText is BringToFont over ScrollView

Thanks for any Help
 
Last edited:
Upvote 0

hopelesscoder4598

Member
Licensed User
Longtime User
Hello
Still not having any luck with the Doevents. I tried putting delays in the code, thinking maybe it needs time for
the keyboard to open. It seems like the Menu opening and closing might be causing the problem.
Thanks for any help.
 
Upvote 0

hopelesscoder4598

Member
Licensed User
Longtime User
Code:
B4X:
Sub Testing_FocusChanged (HasFocus As Boolean)
    If HasFocus Then
        CallSubDelayed(Me,"SetKeyboard_Two" )
    End If
End Sub
Sub mnuTest_click
    Testing.Visible = True
    Testing.BringToFront
    Testing.RequestFocus
End Sub
Sub SetKeyboard_Two
    DoEvents
    IME2.ShowKeyboard(Testing)
End Sub

Hello
This seems to work. I am using FocusChange to call CallSubDelayed(Me,"SetKeyboard_Two").
Having up a lot of Menus items up is where I had a lot of problems. The time the menus open and then
have to close and then show the keyboard.

Thanks for all your help.
 
Last edited:
Upvote 0

Michaell

Member
Licensed User
Longtime User
Ok,
IME1.Initialize("IME")
IME1.ShowKeyboard(EditText1)

... did not work

IME1.Initialize("IME")
DoEvents
IME1.ShowKeyboard(EditText1)
... worked
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Initialize IME in activity_create and show the keyboard on focuschange. You dont need doevents.
 
Upvote 0

Michaell

Member
Licensed User
Longtime User
There is a multi-line EditText called EditText1 inside a Panel in the Activity.

B4X:
Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("3")
   Activity.Title = "XNotes - " & Main.curfile
   EditText1.Text = Main.text
   IME1.Initialize("IME")
   DoEvents
   IME1.ShowKeyboard(EditText1)
End Sub

Starting the activity, this is the only code (that worked for me) to bring up the softkeyboard.
LG phone and Samsung tablet.

I tried focuschanged as suggested and could not get it to work. But thanks for your suggestion. Its interesting that somehow it works for you.
 
Upvote 0
Top