2011-12-24 88 views
0

在我的應用程序中有一個選項來從編輯文本中選擇文本。內容將自動設置爲編輯文本。因此,我把代碼隱藏鍵盤,但當我試圖通過選擇默認菜單來選擇文本時,鍵盤來foreground.i試圖阻止它通過清單文件,但它也不工作在我的device.one事情,我注意到它在一些其他設備工作正常所以這是怎麼回事?請幫助我...如何在編輯文本中選擇默認菜單時隱藏軟鍵盤?

用於隱藏所述軟鍵盤代碼如下

1)

InputMethodManager imm=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); 
imm.hideSoftInputFromWindow(Edittext.getWindowToken(),0); 

XML

<EditText 
     android:id="@+id/editText1" 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentTop="true" 
     android:editable="false"> 
    </EditText> 

2)用來隱藏在特定的活動的softkeyboard(清單文件)碼

<activity android:name=".selecttext" android:label="@string/app_name" android:windowSoftInputMode="stateHidden"></activity> 

<activity android:name=".selecttext" android:label="@string/app_name" 
android:windowSoftInputMode="stateAlwaysHidden"></activity> 

回答

1

嘗試此一爲的EditText ..

edittext.setInputType(InputType.TYPE_NULL);  
if (android.os.Build.VERSION.SDK_INT >= 11) 
{ 
    edittext.setRawInputType(InputType.TYPE_CLASS_TEXT); 
    edittext.setTextIsSelectable(true); 
}