2011-10-06 114 views
0

我在一个片段中有两个布局,我通过使其中一个不可见而另一个可见,并且反之亦然。当包含EditText的布局变得可见时,软键盘会自动弹出。我在清单中使用了以下内容,但没有帮助。每当布局变得可见时都会出现软键盘

android:windowSoftInputMode="stateUnchanged" 

我从来没有明确地请求关注EditText,甚至尝试请求关注别的东西而无济于事。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" android:layout_height="match_parent" 
    android:id="@+id/container"> 
    <LinearLayout android:id="@+id/dial_pad_ll" 
     android:layout_width="match_parent" android:layout_height="match_parent" 
     android:orientation="vertical" android:layout_centerInParent="true" 
     android:background="#1E1E1E" android:layout_marginLeft="20dp" android:layout_marginRight="20dp"> 
     <EditText android:layout_height="wrap_content" android:id="@+id/search_et" 
      android:layout_width="match_parent" android:layout_alignParentTop="true" 
      android:layout_marginTop="20dp" android:layout_marginBottom="10dp" > 
     </EditText> 
     <!-- Other widgets here --> 
    </LinearLayout> 
    <!-- Other Layout Here --> 
</RelativeLayout> 

任何人都知道如何防止这种情况?谢谢。

编辑:我也应该提到,这不是第一次发生。我用编辑文本打开布局1,使其不可见,再次使其可见,然后弹出键盘。

回答

1

尝试将此添加到您的活动中。

this.getWindow().setSoftInputMode(
       WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); 
+0

键盘在切换布局后仍然弹出。在编辑中添加了更多信息。 – FuegoFingers