1:在布局文件中的EditText增加如下属性:
android:imeOptions="actionSearch
2:Java代码中增加如下:
et_input.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if ((actionId == 0 || actionId == 3) && event != null) { return true; } return false; } });
转载请注明原文地址: https://www.6miu.com/read-36092.html