Android Question How to show the keyboard for a DSFloatLabelEditText? (IME not working)

ivan.tellez

Active Member
Licensed User
I have 2 DSFloatLabelEditText of the design support library. For filling the first one I have a buton to use a BarcodeScaner with some code like this:

B4X:
Sub BarcodeOk(Value As String)
    DSFloat1.Text = Value
    DSFloat2.RequestFocus
End Sub

Sub DSFloat2_FocusChanged (HasFocus As Boolean)
    If HasFocus = True Then
        ToastMessageShow("Has the focus", True)
        ime.ShowKeyboard(DSFloat2)
    End If
End Sub

The toast is shown, The DSFloat2 got the focus (prompt is there) but the keyboard does not show until i tap on DSFloat2 view.

I already tried: CallSubDelayed the ime, Sleep before the ime, same both changing the ime call to BarcodeOk.

Maybe is because DSFloatLabelEditText is not a valid View for IME.

Any idea on how to set focus and show the keyboard on a DSFloatLabelEditText?

(Or if has a inner EditText, how to get it to call the ime with it)
 
Last edited:

ivan.tellez

Active Member
Licensed User
Yeap, cant pass the wraper to the IME. Have to Extract the inner View object. Calling this in FocusChanged

B4X:
Sub ShowKeyboard
    Try
        Dim r As Reflector
        r.Target = TxtClave
        r.Target = r.GetField("mEditText")
        Dim jo As JavaObject = r.GetField("object")

        Dim nativeMe As JavaObject
        nativeMe.InitializeContext
        nativeMe.RunMethod("showSoftKeyboard",Array As Object(jo))
    
    Catch
        Log("No Keyboard")
    End Try
    
End Sub
#If Java

public void showSoftKeyboard(android.view.View view){
    if(view.requestFocus()){
        android.view.inputmethod.InputMethodManager imm = (android.view.inputmethod.InputMethodManager) getSystemService(android.content.Context.INPUT_METHOD_SERVICE);
        imm.showSoftInput(view, 0);
    }
}
#End If
 
Top