Android App monitors the keyboard buttons in three ways and changes the keyboard's bottom right corner to determine the key style, androidapp

Source: Internet
Author: User

Android App monitors the keyboard buttons in three ways and changes the keyboard's bottom right corner to determine the key style, androidapp

ActionNone: Enter key. Press the button and move the cursor to the next line.
ActionGo: Go,
ActionSearch: magnifiers
ActionSend: Send
ActionNext: Next
ActionDone: Done, OK/complete, hide the keyboard, even if it is not the last text input box

 

Android: singleline = "true"

Android: imeoptions = "actionSearch"

 

EditText. setoneditexceptionlistener

 

 

@ Override public boolean oneditequaltion (TextView v, int actionId, KeyEvent event) {boolean isOK = true; switch (actionId) {case EditorInfo. IME_ACTION_NONE: Toast. makeText (mContext, "click --> NONE", Toast. LENGTH_SHORT ). show (); break; case EditorInfo. IME_ACTION_GO: Toast. makeText (mContext, "click --> GO", Toast. LENGTH_SHORT ). show (); break; case EditorInfo. IME_ACTION_SEARCH: Toast. makeText (mContext, "click --> SEARCH", Toast. LENGTH_SHORT ). show (); break; case EditorInfo. IME_ACTION_SEND: Toast. makeText (mContext, "click --> SEND", Toast. LENGTH_SHORT ). show (); break; case EditorInfo. IME_ACTION_NEXT: Toast. makeText (mContext, "click --> NEXT", Toast. LENGTH_SHORT ). show (); break; default: isOK = false; break ;}

 

 

<? Xml version = "1.0" encoding = "UTF-8"?> <LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" xmlns: tools = "http://schemas.android.com/tools" android: layout_width = "match_parent" android: layout_height = "match_parent" android: orientation = "vertical" android: paddingBottom = "@ dimen/activity_vertical_margin" android: paddingLeft = "@ dimen/plugin" android: paddingRight = "@ dimen/plugin" android: paddingTop = "@ dimen/plugin" tools: context = "com. edwin. demokeyboard. mainActivity "> <TextView android: layout_width =" match_parent "android: layout_height =" 50dp "android: gravity =" center "android: text =" change the key style in the lower right corner of the keyboard "android: textSize = "20sp"/> <EditText android: id = "@ + id/et_main_one" android: layout_width = "match_parent" android: layout_height = "wrap_content" android: hint = "actionGo" android: imeOptions = "actionGo" android: singleLine = "true"/> <EditText android: id = "@ + id/et_main_two" android: layout_width = "match_parent" android: layout_height = "wrap_content" android: hint = "actionSearch" android: imeOptions = "actionSearch" android: singleLine = "true"/> <EditText android: id = "@ + id/et_main_three" android: layout_width = "match_parent" android: layout_height = "wrap_content" android: hint = "actionSend" android: imeOptions = "actionSend" android: singleLine = "true"/> <EditText android: id = "@ + id/et_main_four" android: layout_width = "match_parent" android: layout_height = "wrap_content" android: hint = "actionNext" android: imeOptions = "actionNext" android: singleLine = "true"/> </LinearLayout>

 

 

 

 

 

 

Source Code address:

Related Article

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.