EditText get focus does not automatically eject keyboard settings

Source: Internet
Author: User

EditText get focus does not automatically eject keyboard settings

The first display with EditText controls automatically gets focus and pops up the keyboard

If you do not want to eject the keyboard automatically, there are two ways:

method One: in the Mainfest file, the corresponding activity settings

Android:windowsoftinputmode= "Statehidden"
or android:windowsoftinputmode= "stateunchanged".


method Two: you can put a hidden textview in the layout, and then Requsetfocus in the OnCreate.

You can put a hidden textview in the layout, and then Requsetfocus in OnCreate.
Note TextView do not set visiable=gone, otherwise it will fail
<textview
Android:id= "@+id/text"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
Android:focusable= "true"
Android:focusableintouchmode= "true"
/>

TextView TextView = (TextView) Findviewbyid (R.id.text);
Textview.requestfocus ();

EditText get focus does not automatically eject keyboard settings

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.