Android, TextWatcher event detected before OnItemClickListener event

My text view (of type AutoCompleteTextView) listens for both TextWatcher and OnItemClickListener.

textView = (AutoCompleteTextView) findViewById(R.id.search_edit_text);

    textView.setOnItemClickListener(this);
    textView.addTextChangedListener(this);

My goal is this: when the user enters a character, a textual representation will be displayed in the drop-down list of the corresponding items containing the entered character (in this case, task A). When the user selects an item from the list, I would like to save it (here task B).
I am running task A within the afterTextChanged area (Editable text) and task B within the onItemClick area (parent element of AdapterView, View v, int position, long id).
Task A works fine, but when I select an item from the list (and expect OnItemClick () to complete task B), then afterTextChanged () is called (perhaps because the text has really changed) before OnItemClick () forces task A again start up. <w> Any idea how to prevent this? Thanks Rob.

+3

Source: https://habr.com/ru/post/1735227/


All Articles