1,首先在布局中添加 android:imeOptions="actionSearch
2,然后java代码中设置代码:
et_input_password.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if ((actionId == 0 || actionId == 3) && event != null) { LogUtil.E(et_input_password.getText().toString().trim());//写你要做的事情 return true; } return false; } });