1

Hi i won't want to show virtual keyboard even user touch the editText field.

Tester
  • 4,115
  • 8
  • 21
  • 16

4 Answers4

6

Have you tried adding android:configChanges="keyboard|keyboardHidden" into your activity?

e.g.:

<activity android:name=".MyApp" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden">

Not sure if it applies to the onscreen keyboard as well as a physical one.

Also you can mess with the On Screen Keyboard using the InputMethodManager, for example to hide it you could use:

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mCurretnView.getWindowToken(), 0);
Pointer Null
  • 36,993
  • 13
  • 79
  • 106
GeekYouUp
  • 1,613
  • 11
  • 10
3

As in this question use:

EditText edtView=(EditText)findViewById(R.id.editTextConvertValue);
edtView.setInputType(0);
Community
  • 1
  • 1
Heidar
  • 500
  • 1
  • 16
  • 33
1
InputMethodManager inputMethodManager = (InputMethodManager) currentActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
if (isShow) {
    if (currentActivity.getCurrentFocus() == null) {
        inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
    } else {
        inputMethodManager.showSoftInput(currentActivity.getCurrentFocus(), InputMethodManager.SHOW_FORCED);    
    }

} else {
    if (currentActivity.getCurrentFocus() == null) {
        inputMethodManager.toggleSoftInput(InputMethodManager.HIDE_NOT_ALWAYS, 0);
    } else {
        inputMethodManager.hideSoftInputFromInputMethod(currentActivity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);    
    }

}
lalosoft
  • 104
  • 6
0

try this

@Override
public boolean dispatchTouchEvent(MotionEvent event) {
    boolean ret = super.dispatchTouchEvent(event);
    InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(mCurretnView.getWindowToken(), 0);  
    return ret;
}

or

editText.setOnTouchListener(new View.OnTouchListener() {

    @Override
    public boolean onTouch(View v, MotionEvent event) {
        InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(mCurretnView.getWindowToken(), 0);  
        return false;
    }
});