欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android取消EditText自動(dòng)獲取默認(rèn)焦點(diǎn)

 更新時(shí)間:2017年03月05日 15:59:45   作者:ganchuanpu  
本文主要介紹了Android取消EditText自動(dòng)獲取焦點(diǎn)默認(rèn)行為的方法,具有很好的參考價(jià)值。下面跟著小編一起來看下吧

最近在通訊錄新建聯(lián)系人=中,一進(jìn)入一個(gè)頁面, EditText默認(rèn)就會(huì)自動(dòng)獲取焦點(diǎn),很是郁悶, 如何讓EditText不自動(dòng)獲取焦點(diǎn)?

那么如何取消這個(gè)默認(rèn)行為呢?

在網(wǎng)上找了好久,有點(diǎn)監(jiān)聽軟鍵盤事件,有點(diǎn)調(diào)用clearFouse()方法,但是測(cè)試了都沒有!xml中也找不到相應(yīng)的屬性可以關(guān)閉這個(gè)默認(rèn)行為

解決之道:在EditText的父級(jí)控件中找一個(gè),設(shè)置成

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>

以上就是本文的全部?jī)?nèi)容,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來一定的幫助,同時(shí)也希望多多支持腳本之家!

相關(guān)文章

最新評(píng)論