How to set the monitor of enter in soft keyboard

Source: Internet
Author: User

/** layout must set properties <singleline & Imeoptions>*/<edittext android:id= "@+id/edt_searchmicrofilm" Android Oid:layout_width= "Fill_parent" android:layout_height= "32DP" android:layout_marginright= "10DP                 "Android:background=" @drawable/search_frame_shape_circle "android:gravity=" center_vertical " android:hint= "@string/plaseinputkeywords" android:paddingleft= "25DP" Android                : textcolorhighlight= "@color/jxinputframehinttextcolor" android:textcolor= "@color/jxtitletextword" android:imeoptions= "Actionsearch" android:singleline= "true" android:textsize= "14SP" &G            T </edittext> 
/** write its own function code in the activity class, that is, set the Listener event: */edittext.setoneditoractionlistene (Newtextview.oneditoractionlistener () { public boolean oneditoraction (TextView v, int ActionId, keyevent event) {if (ActionId = = Editorinfo.ime_action_search | | (Event!=null && event.getkeycode () = = Keyevent.keycode_enter)) {//write the features you want to implement here ...                              return true;                          }                           return false;<pre name= "code" class= "Java" >         }   

I think since you came here to read this article at least want to know how to reset the phone pop-up on the soft keyboardEnterfunction. Make a clickEnterkey, and then respond to the functionality you want to implement. and the interface replacement of the software disk has such a propertyandroid:imeoptionsto meet our needs, this property can take the value of theNormal,actionunspecified,Actionnone,Actiongo,Actionsearch,Actionsend,Actionnext,Actiondone, for example: a value ofActionnextwhenEnterThe key appearance becomes a downward arrow;ActionsearchTimeEnterKey appearance becomes"Search"two characters, and the value isActiondonewhenEnterThe key appearance becomes"Complete"two characters.

When making your own custom response to the feature set, be aware that < below three must meet >:

1. set its properties in the XML layout android:imeoptions, such as;

2. set its properties android:singleline= "true" in the XML layout, guaranteeing that when you click the ENTER key, can be heard correctly;

3. set the Listener in the code:edittext.setoneditoractionlistene (); and complete the function code that you want to implement;




How to set the monitor of enter in soft keyboard

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.