我在我的應用程序中使用一個編輯文本,一旦我完成輸入鍵盤想要自動隱藏而不按回按鈕。誰能幫助我....如何隱藏小鍵盤而不點擊返回按鈕
-1
A
回答
1
在試試這個代碼的Edittext
你會得到選項關閉鍵盤它的自我....
機器人:imeOptions = 「actionDone」
1
你應該使用TextWatcher知道當u完成打字,然後ü可以隱藏下面的鍵盤:鍵入五個字符後
EditText editText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
editText = (EditText)findViewById(R.id.editText);
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if(count == 5){
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);}
}
@Override
public void afterTextChanged(Editable s) {
}
});
}
所以在這個代碼鍵盤會自動隱藏。
試試吧。
1
調用此功能,只要輸入完整獲取
InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
//Hide:
imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
private void hideKeyboard() {
// Check if no view has focus:
View view = this.getCurrentFocus();
if (view != null) {
InputMethodManager inputManager = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
}
1
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
editText.requestFocus();
imm.showSoftInput(editText, 0);
試試這個(在EDITTEXT你應該把你自己的EDITTEXT)。
相關問題
- 1. 如何檢測iPad用戶點擊鍵盤隱藏按鈕?
- 2. 如何在快速點擊返回後隱藏鍵盤
- 3. 如何隱藏鍵盤在UIViewController返回按鈕click-> iphone
- 4. 點擊UIWebView隱藏鍵盤
- 5. IPad鍵盤「隱藏按鈕」
- 6. 如何使鍵盤點擊返回按鈕
- 7. 隱藏鍵盤按鈕被點擊時xamarin形式
- 8. 當按鈕點擊時隱藏鍵盤(片段)
- 9. 「隱藏鍵盤按鈕」的鍵碼
- 10. Android:在按鈕上隱藏鍵盤按
- 11. 按下按鈕隱藏鍵盤
- 12. 如何隱藏點擊按鈕(WordPress的)
- 13. 如何隱藏安卓鍵盤按鈕點擊使用科爾多瓦
- 14. 如何在視圖中隱藏鍵盤消失或點擊按鈕iphone
- 15. 帶文本字段的UIAlertController - 點擊返回按鈕只隱藏鍵盤,不執行操作?
- 16. end當返回按鈕被點擊時鍵盤的編輯
- 17. 點擊一個UIScrollView隱藏鍵盤?
- 18. 隱藏鍵盤時點擊Ext.Form.Select
- 19. 添加一個按鈕隱藏鍵盤
- 20. 檢測iPad的鍵盤隱藏按鈕
- 21. 隱藏返回鍵上的軟鍵盤按
- 22. jQuery隱藏,如果點擊按鈕外
- 23. 按HOME鍵鍵盤不能隱藏
- 24. 在打開的鍵盤按鈕被按下時隱藏LinearLayout一次返回
- 25. 如何隱藏單選按鈕在JavaScript上的按鈕,點擊
- 26. 單擊按鈕時隱藏虛擬鍵盤
- 27. 通過單擊使用Ionic的按鈕來隱藏鍵盤ios
- 28. 無法隱藏鍵盤單擊搜索按鈕在UISearchBar
- 29. 小鍵盤隱藏UITextField
- 30. 帶有「Go」按鈕而不是返回的iOS鍵盤
爲什麼你不想在輸入完成後隱藏鍵盤? –
嗨,你有沒有試過強迫它以任何方式出現?如http://stackoverflow.com/a/10420979/7813290 – Jamin