I need a listener which is called every time the selection in an EditText changes. I googled around but I couldn\'t find anything useful for API level 7. I\'m writing a Text
The better way to do it would be to extend the EditText and then based upon how you would want to manage the changing text, you could override one of the 2 methods to work out your customized behavior.
If you want the selection changed then you could use the onSelectionChanged()
method and implement your code there.
In case you want to implement something when the text changes in your editor then you could use, onTextChanged()
.
Pretty old question, but someone might still need this, so here's my solution : since the text selection accomplished with long press on the text, I simply used the following :
editText.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
// do whatever you need to do on text selection
}
});
This allows for custom behavior on text selection and doesn't prevent the user from copying/pasting.