I am trying to use the following code to hide the soft keyboard when a user clicks a button:
InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
But I get an error:
InputMethodManager not defined
I am thinking I need to add an import statement? If so does anyone know what? Or how can I fix the issue?
InputMethodManager is in package android.view.inputmethod, so you need to add
import android.view.inputmethod.InputMethodManager;
to your class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With