2011-08-23 75 views
0

這裏我寫了簡單的佈局xml。 (有一個listview和edittext)Android軟鍵盤顯示/隱藏控制問題

當我激活這個xml使用普通的setContentView(R.layout.main); 軟鍵盤總是從底部出現。 但是,當我從xml中刪除列表視圖條目時,softkeyboard不顯示。

我不知道列表視圖和軟鍵盤之間有什麼關係。

我從這個網站搜索了類似的問題,並且一些文章提到了使用焦點控制的 解決方案。 但我希望我的xml在沒有軟鍵盤的情況下在edittext上有默認焦點。

有人可以給我一個建議如何解決這個問題?

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="480px" 
    android:layout_height="762px" 
    android:layout_gravity="center" 
    android:background="@drawable/bg_blank" 
    > 

    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     > 

     <ListView 
      android:id="@+id/mylist" 
      android:layout_width="100px" 
      android:layout_height="200px" 
      android:layout_marginLeft="0px" 
      android:layout_marginTop="70px" 
      /> 

     <EditText 
      android:id="@+id/input1" 
      android:layout_width="200px" 
      android:layout_height="50px" 
      android:layout_marginLeft="64px" 
      android:layout_marginTop="400px"   
      /> 
    </RelativeLayout> 

</FrameLayout> 

回答

0

嘗試清單文件中添加以下屬性來你的活動

<activity android:windowSoftInputMode="stateAlwaysHidden" android:name=".Demo"/>