Android – EditText maximum character limit exceeds callback

My idea is to set the error view to EditText when the maximum character limit is reached. Is there a callback for this event, or there may be another way to achieve this effect? Thank you in advance

resolvent:

You can use seterror to edit the text:

editText.addTextChangedListener(new TextWatcher() {         
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            if(s.length() > max)
                editText.setError("Error");
        }
    });

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>