Why can I type into a disabled EditText?

后端 未结 8 1623
时光取名叫无心
时光取名叫无心 2021-01-11 19:52

If I disable an EditText widget using

editText.setEnabled(false);

I can still type into it using the on-screen input method (in

8条回答
  •  清酒与你
    2021-01-11 20:12

    etComment.setEnabled(flag);
    etComment.setFocusable(flag);
    etComment.setFocusableInTouchMode(flag);
    if (flag) {
        etComment.requestFocus();
    }
    etComment.setFilters(new InputFilter[] { new InputFilter() {
        @Override
        public CharSequence filter(
            CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
                if (!flag) {
                    return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
                }
                return null;
            }
        }
    });
    

    for all you can got it!

提交回复
热议问题