The task is this. Some element is selected from the list. For example, there is a "cat, cat" there. I write "ko" choose "cat", i.e. I click on the item "cat", how to handle this choice? I clicked on the cat and I need to perform an action after that.

And another question is how to perform actions when typing each letter?

2 answers 2

You can use TextWatcher.

messageEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { //вызывается перед именением поля } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { //вызывается при изменении текста } @Override public void afterTextChanged(Editable editable) { //вызывается после того, как текст был изменён } }); 

    To get the text of the selected item you need to hang the listener.

      autocompletetv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int position, long id) { String text = parent.getItemAtPosition(position); } });