2 回答
TA贡献1877条经验 获得超1个赞
单击完成按钮时,调用hideSoftInputFromWindow
方法 -
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
TA贡献1807条经验 获得超9个赞
public void hideSoftKeyboard(Context context, View view) {
try {
InputMethodManager inputMethodManager =
(InputMethodManager) context.getSystemService(
Activity.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(
view.getWindowToken(), 0);
} catch (Exception e) {
e.printStackTrace();
}
}
用法
textinputEdit.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if(actionId==EditorInfo.IME_ACTION_DONE){
buttonConfirm.performClick();
hideSoftKeyboard(YourActivityName.this,textinputEdit);
}
return false;
}
});
添加回答
举报