Android @ Kiowok

TextWatcher

There are many ways to respond to changes in a text field.

Assume that you have a reference myText to an EditText object. Then in onCreate you can setup an event handler

	myText.addTextChangedListener(new MyTextWatcher());

where you have defined a TextWatcher class named MyTextWatcher

	class MyTextWatcher implements TextWatcher {
		@Override
public void afterTextChanged(Editable arg0) {
} @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } @Override public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { Log.d("*** YOUR TAG ***", "onTextChanged"); String s = myText.getText().toString(); // process the changed text here... } }
Top