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 , "you click the Soft Keyboard return button" ,toast.length_short). Show ( );} return false
EditText editText2 = (EditText) Findviewbyid (R.ID.TXTTEST2); Edittext2.setoneditoractionlistener (New Oneditoractionlistener () {@Overridepublicbooleanint arg1, KeyEvent ARG2) {if (arg1 = = editorinfo.ime_action_unspecified) {toast.maketext (keyboardactivity. This, "you have clicked the Soft keyboard return button", Toast.length_short). Show (); return false ;}});
Ps:
Set the EditText IME options property to a different value, and you can display different text or patterns on the ENTER key
Actionnone: Enter, press the cursor to the next line
Actiongo:go,
Actionsearch: a magnifying glass
Actionsend:send
Actionnext:next
Actiondone:done, hide soft keyboard, even if not the last text input box
The interface of the software disk is replaced with only one attribute android:imeoptions, the value of this property can be Normal,actionunspecified,actionnone,actiongo,actionsearch, Actionsend,actionnext,actiondone, for example, the Enter key appearance becomes a down arrow when the value is Actionnext, and the ENTER key looks like a "complete" two characters when the values are actiondone.