-
Notifications
You must be signed in to change notification settings - Fork 24
@OnTextChanged
dexafree edited this page Aug 21, 2014
·
1 revision
This annotation will trigger an event when an EditText's text is changed.
##Annotation arguments @OnTextChanged uses an extra "method" argument to specify the listener method which will call this method.
The annotation must be:
@OnTextChanged(value=R.id.edit_text, method=OnTextChanged.Method.BEFORE_TEXT_CHANGED)
// or
@OnTextChanged(value=R.id.edit_text, method=OnTextChanged.Method.ON_TEXT_CHANGED)
// or
@OnTextChanged(value=R.id.edit_text, method=OnTextChanged.Method.AFTER_TEXT_CHANGED)
The method should be this way (the method and variable names can be changed):
- public void beforeTextChanged(CharSequence sequence)
- public void beforeTextChanged(TextView textView, CharSequence sequence)
- public void beforeTextChanged(CharSequence sequence, int start, int count, int after)
- public void beforeTextChanged(TextView textView, CharSequence sequence, int start, int count, int after)
- public void onTextChanged(CharSequence sequence)
- public void onTextChanged(TextView textView, CharSequence sequence)
- public void onTextChanged(CharSequence sequence, int start, int before, int count)
- public void onTextChanged(TextView textView, CharSequence sequence, int start, int before, int count)
- public void afterTextChanged(Editable editable)
@OnTextChanged(value=R.id.edit_text, method=OnTextChanged.Method.ON_TEXT_CHANGED)
public void onTextChanged(CharSequence sequence) {
Toast.makeText(this, "Sentence written: $sequence", Toast.LENGTH_SHORT).show();
}