Android Soft keyboard Enter key capture

Source: Internet
Author: User

 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.