Android cancels EditText to automatically obtain the default focus behavior, androidedittext

Source: Internet
Author: User

Android cancels EditText to automatically obtain the default focus behavior, androidedittext

Recently, when a new contact = in the address book enters a page, EditText automatically obtains the focus by default, which is very depressing. How can I disable EditText to automatically obtain the focus?

So how to cancel this default behavior?

I have been searching for it online for a long time. I have listened to a soft keyboard event and called the clearFouse () method, but I have not tested it! You cannot find the corresponding attribute in xml to disable this default behavior.


Solution: find one in the parent control of EditText and set it

android:focusable="true"  android:focusableInTouchMode="true"  

Demo. xml:

<?xml version="1.0" encoding="utf-8"?>  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"      android:layout_width="fill_parent"      android:layout_height="fill_parent"      android:background="#ffffff"      android:baselineAligned="false"      android:focusable="true"       android:focusableInTouchMode="true" >                     <RelativeLayout                  android:layout_width="250dp"                  android:layout_height="wrap_content"                  android:id="@+id/txtLayout"                   android:layout_marginTop="20dp"                  android:layout_centerHorizontal="true"                 >              <EditText                   android:layout_width="fill_parent"                  android:layout_height="35dp"                  android:id="@+id/editPhone"                  android:phoneNumber="true"                  android:text="@string/txtaddPhone"                  android:textColor="#D8D8D8"                  android:background="@drawable/txtupbg"                  android:textSize="15dp"                  />            </RelativeLayout>  </RelativeLayout>

  

  

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.