方法一(實測可行):
參考http://www.cnblogs.com/dream-cichan/p/aaaa.html
當我點擊跳轉至一個帶有EditText的界面后,模擬器中的軟鍵盤會自動彈出,嚴重影響了用戶體驗。在網上找了資料,現總結如下。
我們知道,EditText有一個 android:focusable=""的屬性,但是如果你在edittext中直接將這個屬性設置為true的話,點進去軟鍵盤確實不會再彈出,但是EditText相應的也失去了聚焦,即無論你怎么點擊它都不會有反應,這也就失去了EditText的原本的作用。那么要解決這個問題其實很簡單,只需在EditText的父控件中加上這兩行代碼即可:
android:focusable="true"
android:focusableInTouchMode="true"
示例:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:focusable="true" android:focusableInTouchMode="true" > <EditText android:id="@+id/editText_search" android:layout_width="match_parent" android:layout_height="40dp" android:hint="Search" /> <ListView android:id="@+id/questionsListView" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </LinearLayout>
我的理解是整個焦點聚在父控件的界面上了,所以也就不會單單聚焦在EditText上。
方法二(未測試):
參考:http://blog.csdn.net/cwc455826074/article/details/6880444?reload
比如我進入一個設置界面,里面如果EditText,那么這時候輸入框就會自動彈出,那么如何屏蔽這個輸入框呢? 到我們點擊EditText的時候才彈出輸入框呢?
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS