0

In one of my screen i am using text watcher to check value against a range and for invalid range color of text is being changed. Now there is one more requirement. Along with EditText i need to use CheckBox to set completely different range.

The problem i am facing is that changing the checkbox value requires to call afterTextChanged in which i have put all validations for both set of ranges.

So basically my requirement is to update textWatcher anyhow so that afterTextChanged get called after i change value of checkbox.

I get a strange feeling that i am forgetting something very simple here,if so please let me know. Thanks in advance.

kaushal trivedi
  • 3,405
  • 3
  • 29
  • 47

1 Answers1

0

Perhaps move your code from the callback in the textWatcher and put it into another function ie

private void checkRange() {
    // do checks here
    String color = text.getEditableText().toString();
}

and call this method from your textWatcher and from the listener on the checkbox.

Rhys Davis
  • 996
  • 7
  • 16
  • Hi, Actually it is lots of code and i have intentionally not put the same code in checkbox because it is only used to set the range. You may be right,but i really want to know it by this way if it is possible or not.Still thanks for your reply. – kaushal trivedi Mar 14 '14 at 08:39