我有一個5編輯文本和3個單選按鈕和兩個按鈕的佈局。5編輯文本後,我有3個單選按鈕,然後2個按鈕。在第五編輯文本中輸入文本後,由於軟鍵盤,我無法看到單選按鈕和普通按鈕。輸入第五個編輯文本後,如何禁用該軟鍵盤?任何一個可以請幫我出這個問題...在編輯文本中輸入文字後無法隱藏軟鍵盤
回答
試試下面的代碼隱藏/關閉軟鍵盤
getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN
);
在上次編輯tetx中輸入文本後,它隱藏了軟鍵盤?我申請了InputMethodManager imm =(InputMethodManager)getSystemService( \t \t Context.INPUT_METHOD_SERVICE); \t \t imm.hideSoftInputFromWindow(country.getWindowToken(),0);代碼爲最後的編輯文本值 – yamuna
public void hideKeyBord(View view) {
if (view != null) {
if (keyBoardHide == null) {
keyBoardHide = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
}
if (keyBoardHide != null && keyBoardHide.isActive()) {
// to hide keyboard
keyBoardHide.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
}
InputMethodManager inputManager = (InputMethodManager)
getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
只需使用:
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
每當你想隱藏軟鍵盤。
你的情況: 讓你的第五EditText
是et
.. 然後使用:
if(!et.toString().equals(null)){
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}
OR
您可以檢測,如果第五EditText
是focused
或不是,然後行事科丁(即使用該方法隱藏鍵盤上方如果EditText
是focused
)按照以下的鏈接:
How can I detect focused EditText in android?
OR
軟鍵盤上檢測Done
鍵事件:
按下DONE
按鈕時,鍵盤會自動關閉。但是,如果要執行時,按下按鈕DONE
海關措施,請參見下文:
et= (EditText) findViewById(R.id.edit_text);
et.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
// do your stuff here
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}
return false;
}
});
希望這有助於!
隱藏鍵盤不是一個大問題,但你需要確認「什麼時候?」 需要調用
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(edittext.getApplicationWindowToken(), 0);
隱藏softkeyboard
嘗試在你的EditText XML文件中添加android:imeOptions="actionNext"
和
edittext.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
boolean flag= false;
if (i == EditorInfo.IME_ACTION_NEXT) {
flag= true;
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(edittext.getApplicationWindowToken(), 0);
}
return flag;
}
});
這個代碼會隱藏你的軟鍵盤上點擊旁邊的鍵盤
在所有編輯文本字段填充後不顯示 – yamuna
- 1. Softwindow鍵盤隱藏編輯文本
- 2. Android:鍵盤隱藏編輯文本
- 3. Android鍵盤隱藏文本輸入
- 4. 編輯文本隱藏在屏幕鍵盤後
- 5. 如何在編輯文本中選擇默認菜單時隱藏軟鍵盤?
- 6. Android:隱藏軟輸入鍵盤
- 7. 鍵盤隱藏在輸入文本到文本框之間
- 8. 無法隱藏Android的軟鍵盤,即使輸入管理
- 9. jQuery Mobile Force在對焦文本輸入框中隱藏軟鍵盤
- 10. 無法隱藏EditTextPreference的軟鍵盤
- 11. 如何在隱藏文本字段時解析android軟鍵盤?
- 12. 隱藏軟鍵盤
- 13. 在輸入文本框中隱藏移動設備的鍵盤
- 14. 進入後隱藏輸入文本,輸入後隱藏密碼
- 15. 鍵盤隱藏文本框
- 16. 鍵盤隱藏文本框
- 17. 如何在Xamarin Android中隱藏鍵盤後單擊外部編輯文字
- 18. 隱藏在文本編輯
- 19. 的XCode文本字段隱藏鍵盤
- 20. 在Android 4中的EditText中輸入時隱藏軟鍵盤
- 21. 用於隱藏軟鍵盤的代碼在編輯文本中選擇默認菜單後在android
- 22. 如何防止Android鍵盤隱藏編輯文本?
- 23. 虛擬鍵盤隱藏編輯文本,從片段設置
- 24. 如何在離開編輯框時隱藏軟鍵盤?
- 25. Android軟觸摸鍵盤隱藏輸入字段
- 26. 從輸入法服務隱藏軟鍵盤
- 27. Worklight/Dojo - 鍵盤隱藏輸入字段
- 28. 鍵盤隱藏輸入字段的WebView
- 29. android編輯文本在按下任意鍵時隱藏在鍵盤下方
- 30. 文本編輯鍵盤
理想情況下,你不應該這樣做,因爲它取決於用戶,以確定他是否正在編輯。所以用戶不應該是關閉鍵盤的人嗎? – Droidekas