Android Question Hide keyboard without IME

npsonic

Active Member
Licensed User
Is there any way to hide keyboard without use of IME?
Use of IME prevents use of "adjustPan|stateHidden".
 

npsonic

Active Member
Licensed User
Okay, no problem any more. I found a way, maybe this will help someone with same problem.

B4X:
Sub HideKeyboard (target As View)
    Dim nativeMe As JavaObject
    nativeMe.InitializeContext
    nativeMe.RunMethod("hideSoftKeyboard",Array As Object(target))
End Sub
#If Java
public void hideSoftKeyboard(android.view.View view){
  android.view.inputmethod.InputMethodManager imm = (android.view.inputmethod.InputMethodManager)getSystemService(android.content.Context.INPUT_METHOD_SERVICE);
  imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
#End If
 
Upvote 0

npsonic

Active Member
Licensed User
B4X:
Sub ShowKeyboard (target As View)
    Dim nativeMe As JavaObject
    nativeMe.InitializeContext
    nativeMe.RunMethod("showSoftKeyboard",Array As Object(target))
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,android.view.inputmethod.InputMethodManager.SHOW_IMPLICIT);
    }
}
#End If
 
Upvote 0

npsonic

Active Member
Licensed User
I'm not sure if I understand. If I add "adjustResize" into manifest, layout is not adjusted, keyboard just goes over the EditText.
B4X:
SetActivityAttribute(main, android:windowSoftInputMode, adjustResize|stateHidden)

If I use "adjustPan" layout will be adjusted, but there is no way to use IME without breaking this.
 
Last edited:
Upvote 0

npsonic

Active Member
Licensed User
Yes, you are right. Thanks for the clarification.
 
Upvote 0
Top