in Android Code Tips

EditText: handle text changes

If you want to listen for text changes at a editText you will probably use the onKeyListener listener. That’s ok if you are using the hardware keyboard, but how will you detect the keydown event from a software keyboard?

addTextChangedListener is your new onKeyListener

		searchBox = (EditText) findViewById(;
		searchBox.addTextChangedListener(new TextWatcher() {

			public void onTextChanged(CharSequence s, int start, int before, int count) {

			public void beforeTextChanged(CharSequence s, int start, int count, int after) {


			public void afterTextChanged(Editable s) {
				String typedText = s.toString();