我有三個編輯文本字段。在這些字段中,我希望僅爲第一個字段顯示軟輸入鍵盤,並在後兩個字段中顯示禁用的日期和時間字段。隱藏Android軟鍵盤(如果打開的話)
Edit-Text 1 //Show the keyboard
Edit-Text 2 and 3 //Hide the keyboard
通過使用下面的代碼,我能夠禁用鍵盤場2和3,但是當用戶集中於1場的鍵盤出現,但是當用戶點擊場2或3並沒有隱瞞。儘管先敲擊第2或第3場,但不會出現鍵盤。
//Code to disable soft input keyboard
public static void disableSoftInputFromAppearing(EditText editText) {
if (Build.VERSION.SDK_INT >= 11) {
editText.setRawInputType(InputType.TYPE_CLASS_TEXT);
editText.setTextIsSelectable(true);
} else {
editText.setRawInputType(InputType.TYPE_NULL);
editText.setFocusable(true);
}
如何隱藏軟輸入鍵盤,如果它已經打開?
我在片段上 – Paras