[英]How to hide soft keyboard for one of the EditText when soft keyboard is already shown?
這里的情況:我正在顯示一個帶有4個輸入字段的屏幕,其中2個需要由用戶編輯(數字字段),其他(文本字段) - 顯示一些文本信息,可由用戶通過ListView更改,但它已關閉用於手動編輯。 我在我的XML文件android:editable="false"
使用非數字EditText字段,它有助於在用戶單擊字段時禁用軟鍵盤的彈出窗口。 但問題在於當用戶編輯數字字段時,軟鍵盤在用戶關注文本字段后沒有隱藏。
那么當用戶專注於我的文本字段時,如何隱藏已經顯示的軟鍵盤?
方法如:
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(MEdit1.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
或類似的東西
MetricEdit = (EditText) findViewById(R.id.MetricEdit);
MetricEdit.setInputType(0);
不起作用。
在此先感謝您的時間。
試試看
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(MEdit1.getWindowToken(), 0);
在onclicklistener中可編輯的edittext
您還可以更改數字edittext的鍵盤,在底部使用以下內容進行“完成”:
android:imeOptions="actionDone"
在edit.xml的xml中
這會有所幫助..
edittext.setInputType(InputType.TYPE_NULL);
if (android.os.Build.VERSION.SDK_INT >= 11)
{
edittext.setRawInputType(InputType.TYPE_CLASS_TEXT);
edittext.setTextIsSelectable(true);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.