view.requestFocus()
是不足够的;
我正在使用这段代码:
public static void setSoftwareKeyboardVisibility(Context context, View view, boolean value) {
final InputMethodManager manager = (InputMethodManager) context.getSystemService(Service.INPUT_METHOD_SERVICE);
if (value) {
view.requestFocus();
manager.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
} else {
// Any other not EditText View
manager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.RESULT_UNCHANGED_SHOWN);
view.requestFocus();
}
}
但是您说标准方法不起作用。尝试调用showSoftInput
not inOnFocusChange
方法。当您将焦点设置在 EditText 上时调用它。