0

I am working on a project with an AutoCompleteTextView. I've put some buttons to work as a keyboard the problem is when i click(focus) on the autocompletetextview the soft keyboard appears i dont want it to appear at all i have tried use this .

View view = this.getCurrentFocus();
    if (view != null) {
        InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    } 

but this seems only to work if i put it in an onclick (button) and it is used to hide the keyboard while i need to disable it completely...any ideas?

Flimzy
  • 68,325
  • 15
  • 126
  • 165
  • https://stackoverflow.com/questions/5803193/android-disable-soft-keyboard-at-all-edittexts check this – rafa May 26 '18 at 02:47

1 Answers1

1
public static void hideKeyboard(Activity activity) {
    View view = activity.findViewById(android.R.id.content);
    if (view != null) {
        InputMethodManager imm = 
            (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}

You can call this method on button click Maybe this helps you.

wazz
  • 4,758
  • 5
  • 19
  • 33
Bhupat Bheda
  • 2,066
  • 1
  • 7
  • 13