2

I have a textinputedittext with input type=number. To close the keypad if user clicks anywhere other than textinputedittext i used the following function -

public static void hideSoftKeyboard(Activity activity) {
    InputMethodManager inputMethodManager =
            (InputMethodManager) activity.getSystemService(
                    Activity.INPUT_METHOD_SERVICE);
    inputMethodManager.hideSoftInputFromWindow(
            activity.getCurrentFocus().getWindowToken(), 0);
}

But instead of keyboard getting closed , it simply converts to alpha-numeric(default) keyboard , and then when there is second click the the keyboard closes. I am unable to understand as to why the keyboard instead of closing converts to alpha-numeric.

Apoorv Singh
  • 1,295
  • 1
  • 14
  • 26

1 Answers1

3
android:focusableInTouchMode="false"

adding this attribute on parent layout of screen solved the issue.

Apoorv Singh
  • 1,295
  • 1
  • 14
  • 26