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

Android取消EditText自動獲取默認焦點

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

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

那么如何取消這個默認行為呢?

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

解決之道:在EditText的父級控件中找一個,設置成

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>

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

相關文章

最新評論