Android Development in EditText Click enter key focus change processing (get focus and lose focus interactive change)

Source: Internet
Author: User

Recently, because of the project needs, the focus of the edittext needs to be shifted to Lineralayout: After you have entered the EditText, click the Enter key or press OK on other embedded Android devices to get the Lineralayout click event.

This method can be called Initlistener in the OnCreate method;

  

1     /**2 * Listen to the focus of the EditText, click the Enter key (or press OK), lose focus, turn focus to ImageView3      */4     Private voidInitlistener () {5Mettrainid.setoneditoractionlistener (NewTextview.oneditoractionlistener () {6              Public BooleanOneditoraction (TextView V,intActionId, KeyEvent event) {7                 if(ActionId = =Editorinfo.ime_action_send8|| (Event! =NULL&& Event.getkeycode () = =keyevent.keycode_enter)) {9Mettrainid.setfocusable (false);TenMllfunction.setfocusable (true); One Mllfunction.requestfocus (); A Mllfunction.findfocus (); -                     return true; -                 } the                 return false; -             } -         }); -}

  

Android Development in EditText Click enter key focus change processing (get focus and lose focus interactive change)

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.