In Android, edittext loses focus

Source: Internet
Author: User

In our applications, when you enter a page, edittext automatically obtains the focus by default. The input method box is displayed, and the user experience is poor,

So how to cancel this default behavior?

I have been searching for it online for a long time. I have a method for listening to Soft Keyboard Events. I have called the clearfouse () method, but I can't even test it! You can disable this default behavior if the corresponding attributes cannot be found in the corresponding XML.

After studying it, add the following attributes under its parent control to solve the problem perfectly:

Android: focusable = "true"
Android: focusableintouchmode = "true"

Example:

<Linearlayout Android: layout_width= "Fill_parent"Android: layout_height= "Wrap_content"Android: Orientation= "Horizontal"Android: focusable

= "True"Android: focusableintouchmode= "True"

  edittext Android: ID  = "@ + ID/et_enter_msg_content"  Android: layout_width  =" wrap_content " Android: layout_height  = "wrap_content"  Android: layout_weight  = "1"/>  button Android: ID  = "@ + ID/sent"  Android: layout_width  = "wrap_content"  Android: layout_height  = "wrap_content"  Android: Text  =" @ string/Send "/>  

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.