我正在Android上編寫應用程序,我有這些按鈕;當你點擊它們時,如果輸入面板(EditText)不可見,則它會出現,否則它會消失。 問題是用戶仍然可以輸入到EditText中,即使消失後也是如此。我附上了兩張照片來展示我的意思。如何禁用鍵入EditText一旦其Visibilty設置爲消失
我試圖.setEnabled(false)
- 沒有工作。我試過.setFocusable(false)
- 沒有工作。
我一起嘗試 - 沒有工作。
我正在Android上編寫應用程序,我有這些按鈕;當你點擊它們時,如果輸入面板(EditText)不可見,則它會出現,否則它會消失。 問題是用戶仍然可以輸入到EditText中,即使消失後也是如此。我附上了兩張照片來展示我的意思。如何禁用鍵入EditText一旦其Visibilty設置爲消失
我試圖.setEnabled(false)
- 沒有工作。我試過.setFocusable(false)
- 沒有工作。
我一起嘗試 - 沒有工作。
在設置可視性之前,您可以嘗試隱藏軟鍵盤。
InputMethodManager imm = (InputMethodManager) YourActivity.this.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editView.getWindowToken(), 0);
我想你需要關閉Android軟鍵盤。此鏈接將幫助您解決問題:Close/hide the Android Soft Keyboard
這些這些問題的答案說,你可以使用輸入過濾
editText.setFilters(new InputFilter[] {
new InputFilter() {
public CharSequence filter(CharSequence src, int start,
int end, Spanned dst, int dstart, int dend) {
return src.length() < 1 ? dst.subSequence(dstart, dend) : "";
}
}
});
可以使用TextWatcher非常久遠的標誌http://developer.android.com/reference/android/text/TextWatcher.html
準備邏輯,一旦公開程度,然後去在public void onTextChanged(CharSequence s, int start, int before, int count)
把相同的文本作爲較早
指這也Android TextWatcher.afterTextChanged vs TextWatcher.onTextChanged
不,沒有工作:/好主意,但。 – 2011-12-22 16:26:31
我的不好。它現在有效!謝謝 :) – 2011-12-22 16:41:36