If you have to perform certain tasks before, after and during the text changes in android EditText the following methods will help you to monitor your operations. Implementing the Textwatcher interface provides the callback methods listed below, these basic methods will also determine the number of characters inserted.
public void beforeTextChanged(CharSequence s, int start, int count, int after);
public void onTextChanged(CharSequence s, int start, int before, int count);
public void afterTextChanged(Editable s);
Example:-
etTextChange.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
textCount = etTextChange.getText().length();
setTitle(String.valueOf(textCount));
Log.e(TAG, String.valueOf(textCount))
}
@Override
public void afterTextChanged(Editable s) {
}
});
0 Comment(s)