0

I have an EditText that I empty after anything is typed into it (for whatever reason). I do this by calling setText("")

Everything works fine, unless the user is not on the default keyboard state (the number state for instance). Because setText calls InputMethodManager.restartInput after a key is pressed in the non-default state and I then call setText(""), restartInput() gets called, and the keyboard switches back to the default state (in most cases the "ABC" state).

This is very annoying if the user needs to type multiple numbers or special characters, etc... Is there any way to do this without restartInput getting called?

Eliezer
  • 7,209
  • 12
  • 56
  • 103

1 Answers1

1

You can try implementing a text watcher on your edittext. In method onTextChanged(), you can use setText(""). You'll not have to deal with ImputMethodManager that way.

DroidDev
  • 1,527
  • 4
  • 20
  • 42
  • I'm already using a `TextWatcher` with `afterTextChanged` and I call `setText("")` in there. There are also places outside of the `TextWatcher` where I would need to call `setText("")` so that wouldn't work anyways. – Eliezer Jan 15 '14 at 07:58