public class KeyboardUtils {
//传进来的view要是EditText
public static void openSoftInput(View view, Context context) {((InputMethodManager) context
.getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(
view, InputMethodManager.RESULT_SHOWN);
}
public static void closeSoftInput(View view, Context context) {
((InputMethodManager) context
.getSystemService(Context.INPUT_METHOD_SERVICE))
.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
调用:
public void OpenKeyboard(View view) {
KeyboardUtils.openSoftInput(eText, this);
}
public void CloseKeyboard(View view) {
KeyboardUtils.closeSoftInput(eText, this);
}