How to limit specific character in edit text?
问题 My question is that How to limit specific character in edit text? for example I want to limit # character using max. 3 times in edit text. How can I do this? Any advice or code sample please. thanks. 回答1: use this yourEditText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if(count>3){ yourEditText.setEnabled(false); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {