0

I am designing my own keyboard, so i dont want the default keyboard to appear.

I am able to achieve this, but the focus on selection is missing.
How can i have the focus but disable the Keyboard alone on EditText in Android?

Infinite Recursion
  • 6,511
  • 28
  • 39
  • 51
Ranjith
  • 510
  • 3
  • 10

1 Answers1

0

add this listener for edittext:

edit_Text.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
  if(hasFocus){
      hideSoftKeyboard();
  }
  }
});

and add this method to activity:

public static void hideSoftKeyboard() {
  InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
  inputMethodManager.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), 0);
}
Ahmad Ronagh
  • 790
  • 10
  • 16