cptKopernikus cptKopernikus - 1 year ago 87
Java Question

EditText changedListener is not getting called

I use an

to filter some values in an

It works so far, but I have one problem. First my code:

final EditText mEditText = (EditText) this.findViewById(R.id.filterEditText);
mEditText.addTextChangedListener(new TextWatcher() {
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}

public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { }

public void afterTextChanged(Editable editable) {
String mFilter = editable.toString();
Log.d("Editable", editable.toString());

The method
gets called when I type something in and the filter is applied and works.

But if I delete everything in the
, the
stays at it last filtered state until I close the keyboard and then it shows all values again.

Is there a way to show all values eevn if the EditText is empty but the Keyboard is not collapsed?

Best regards!

Answer Source

Put all of your code into the onTextChanged() method instead of the afterTextChanged() method.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download