Android 手动关闭软键盘时的警告
单击按钮时,我使用以下代码关闭EditText的软键盘:Android 手动关闭软键盘时的警告,android,android-edittext,android-softkeyboard,android-input-method,Android,Android Edittext,Android Softkeyboard,Android Input Method,单击按钮时,我使用以下代码关闭EditText的软键盘: public void closeSoftInput(){ final Context c = this.getContext(); if(c==null) return; editText.clearFocus(); InputMethodManager imm = (InputMethodManager)c.getSystemService( Context.
public void closeSoftInput(){
final Context c = this.getContext();
if(c==null)
return;
editText.clearFocus();
InputMethodManager imm = (InputMethodManager)c.getSystemService(
Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editText.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
这很好,但每次我调用closeSoftInput时都会收到以下警告:
10-01 21:55:13.075: W/IInputConnectionWrapper(25021): getSelectedText on inactive InputConnection
10-01 21:55:13.075: W/IInputConnectionWrapper(25021): setComposingText on inactive InputConnection
10-01 21:55:13.075: W/IInputConnectionWrapper(25021): getExtractedText on inactive InputConnection
如果按back键关闭键盘,则不会抛出任何警告。
为什么在执行closeSoftInput时抛出它们
Thx您是否使用输入连接和输入的文本?否。我刚刚在编辑文本中添加了一个TextWatcher