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?

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
  • https://stackoverflow.com/questions/5803193/android-disable-soft-keyboard-at-all-edittexts check this – rafa May 26 '18 at 02:47

1 Answers1

0
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,953
  • 5
  • 20
  • 34
Bhupat Bheda
  • 1,968
  • 1
  • 8
  • 13