Cancel textchange listener event

I have a edittext with a textchange listener. In the listener I test if the input of the user is where I want to test if the input is within the min-max boundaries.

valueText.addTextChangedListener(new TextWatcher() {
    String backup = "0";

    public void onTextChanged(CharSequence s, int start, int before, int count) {
        if (count > 0 && !s.equals(backup)) {
            if (Integer.parseInt(s.toString()) > getMaximum()) {

    public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        backup = s.toString();

    public void afterTextChanged(Editable s) {

At the moment I have this, but is there an easy way to 'cancel' the textchange event so nothing happens when the value is above the maximum?

Or can i use a inputfilter where I can set the min and max input?

Thx :)

EDIT: I found a solution here:


You can use android:maxLength on your EditText XML definition.

 InputFilter.LengthFilter mLenthFilter=new InputFilter.LengthFilter(25); // pls define yr max length mine was 25.
        valueText.setFilters(new InputFilter[]{mLenthFilter});, with this you can set the min and max value of an edittext.

Need Your Help

PHP - XML not parsed

php xml web-services curl fsockopen

I'm tryng to send an request to Cielo's webservice, but if i send with curl, fsockopen or other, it doesn't work, and if I post an form, it work perfectly...

Javascript popup window (minimum) height

javascript popup window

I am creating a simple popup window and the window height will not resize to 30 pixels. It always defaults to 100 pixels. This behavior appears in all browsers. Am I missing something?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.