[Android Note] The EditText text box does not get the focus, androidedittext

Source: Internet
Author: User

[Android Note] The EditText text box does not get the focus, androidedittext

This is often the case during development. After opening an activity,

The first text box automatically obtains the focus, and the keyboard input box is displayed.This affects the user experience.

Solution:

1. Do not let the text box get the focus and preemptible the focus of the text box, such as adding it to its parent form:

 1 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 2     xmlns:tools="http://schemas.android.com/tools" 3     android:layout_width="match_parent" 4     android:layout_height="match_parent" 5     android:orientation="vertical" 6     android:focusable="true" 7     android:focusableInTouchMode="true" 8     tools:context=".MainActivity" > 9      10      <EditText11         android:id="@+id/etMsg"12         android:layout_width="wrap_content"13         android:layout_height="wrap_content"14         />15 </LinearLayout>

2. Do not bring up an input box to get the focus. Add the following to the activity:

 

1 android:windowSoftInputMode = "stateHidden"

 

Http://my.oschina.net/helu/blog/142020 ()

 

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.