Cancel textchange listener event
<p>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.</p>

<pre><code>valueText.addTextChangedListener(new TextWatcher() {
    String backup = "0";

    public void onTextChanged(CharSequence s, int start, int before, int count) {
        if (count &gt; 0 &amp;&amp; !s.equals(backup)) {
            if (Integer.parseInt(s.toString()) &gt; getMaximum()) {
                valueText.setText(backup);
            }
        }
    }

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

    public void afterTextChanged(Editable s) {
    }
});
</code></pre>

<p>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? </p>

<p>Or can i use a inputfilter where I can set the min and max input? </p>

<p>Thx :) </p>

<p>EDIT: I found a solution here: <a href="http://tech.chitgoks.com/2011/06/27/android-set-min-max-value-an-edittext-accepts/" rel="nofollow">http://tech.chitgoks.com/2011/06/27/android-set-min-max-value-an-edittext-accepts/</a></p>
