2012-04-12 145 views
0

我想隱藏EditText上的軟鍵盤,即使在'點擊'時也是如此。我的意思是說在我的活動中不應該有可見的軟鍵盤,因爲我有自己的鍵盤來輸入數據。 請幫我...謝謝...如何隱藏EditText上的軟鍵盤

+1

可能重複[How t o關閉/隱藏Android軟鍵盤?](http://stackoverflow.com/questions/1109022/how-to-close-hide-the-android-soft-keyboard) – 2012-04-12 10:20:54

+0

@Adil Soomro,我無法獲得從該鏈接解決方案...仍然軟鍵盤是可見的,當我點擊edittext ... – Noundla 2012-04-12 11:02:51

+0

看到這篇文章http://stackoverflow.com/a/1109108/985143 – 2012-04-12 10:16:05

回答

3
editText_input_field.setOnTouchListener(otl); 

private OnTouchListener otl = new OnTouchListener() { 
public boolean onTouch (View v, MotionEvent event) { 
     return true; // the listener has consumed the event 
} 
}; 

來源:how to block virtual keyboard while clicking on edittext in android?

+1

這是很好的,在這裏我們必須把重點放在指定的視圖,這就是爲什麼我們必須得到這個請求。所以最好在上面加上'((EditText)v).requestFocus()'return true;' – Noundla 2012-04-12 11:27:30

+0

沒有@Noundla的評論編輯框將不會專注於觸摸 – 2017-04-18 23:59:00

1

設置的EditText小部件的的inputType到null這樣,

editTExt.setInputType(TYPE_NULL); 
+0

什麼是TYPE_NULL? – Noundla 2012-04-12 11:05:53

+0

@noundla ..它在** InputType **類中的一個常量..嘗試** InputYpe.TYPE_NULL ** – ngesh 2012-04-12 11:08:03

+0

行..它是工作正常的唯一已經焦點的編輯文本..如果我移動到另一個編輯文本那麼softkeyboard來... – Noundla 2012-04-12 11:14:43

0

粘貼如下代碼下的EditText XML文件標籤

android:textIsSelectable="true"