0

I was creating CustomAutoCompleteTextView extends AppCompatAutoCompleteTextView and i want to handle key event (any button press) but i don't want to use Textwatcher (etc addTextChangedListener(new TextWatcher()). How i can to detect key event by another method ? like (onKeydown) , but for all buttons. is it possible ?

ilw
  • 2,499
  • 5
  • 30
  • 54
  • 1
    you dont need it (in fact you dont need TextWatcher as well), all you need is an adapter that implements `Filterable` interface – pskink Jul 09 '16 at 16:22
  • 1
    also read `KeyEvent` docs: """As soft input methods can use multiple and inventive ways of inputting text, there is no guarantee that any key press on a soft keyboard will generate a key event: [...], and in fact sending such events is discouraged. You should never rely on receiving KeyEvents for any key on a soft input method. In particular, the default software keyboard will never send any key event to any application targetting Jelly Bean or later, and will only send events for some presses of the delete and return keys to applications targetting Ice Cream Sandwich or earlier""" – pskink Jul 10 '16 at 06:05
  • As i said, you dont need any `TextWatcher`, where does your data come from? web interface, local sqlite db? – pskink Jul 10 '16 at 07:14
  • `AutoCompleteTextView` without the adapter? it will not work, sorry... – pskink Jul 10 '16 at 07:17
  • so you have to call `setAdapter`, and use the adapter that implements `Filterable` intarface, where does your data come from? web interface, local sqlite db? – pskink Jul 10 '16 at 07:19
  • so what is your problem really? where does your data come from? web interface, local sqlite db? – pskink Jul 10 '16 at 07:22
  • finally... so use a `SimpleCursorAdapter` and setup its `FilterQueryProvider`, that's all, no need for any custom `ACTV` – pskink Jul 10 '16 at 07:23
  • 1
    and in practice it works like [this](http://stackoverflow.com/a/19860624/2252830) – pskink Jul 10 '16 at 07:34
  • of course you dont need to use `MatrixCursor` but directly call `SQLiteDatabase#query` / `SQLiteDatabase#rawQuery` to return the `Cursor` – pskink Jul 10 '16 at 08:42

0 Answers0