android 软键盘回车键捕获
EditText editText2 = (EditText)findViewById(R.id.txtTest2);
editText2.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView arg0, int arg1, KeyEvent arg2) {
if (arg1 == EditorInfo.IME_ACTION_UNSPECIFIED) {
Toast.makeText(KeyBoardActivity.this, "你点了软键盘回车按钮",
Toast.LENGTH_SHORT).show();
}
return false;
}
});
软件盘的界面替换只有一个属性android:imeOptions,这个属性的可以取的值有normal,actionUnspecified,actionNone,actionGo,actionSearch,actionSend,actionNext,actionDone,例如当值为actionNext时enter键外观变成一个向下箭头,而值为actionDone时enter键外观则变成了“完成”两个字。