这里 fragment :
searchViewEditText.setImeOptions(EditorInfo.IME_ACTION_DONE);
searchViewEditText.setSingleLine(true);
因此,当键盘打开时,会显示按钮完成。 好的。
结果如下:
但是当我点击按钮完成时什么也没有发生。我希望键盘会被隐藏。
最佳答案
您可以使用它(设置在 EditText 上执行操作时调用的特殊监听器),它适用于 DONE 和 RETURN:
max.setOnEditorActionListener(new OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
Log.i(TAG,"Enter pressed");
}
return false;
}
});
关于android - 搜索 View : when click Done button nothing happens,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47327001/