serenskye
serenskye

Reputation: 3467

AutoCompleteTextView showDropDown not working

I am asynchronously loading data, I have an AutoCompleteTextView, when the data loads it is set in the adapter When I click on the search view I want to show the user all results. I can confirm the onClickListener is being called, but the results show only the second time I click.

  private View.OnClickListener onAutoCompleteClickListener = new View.OnClickListener(){
   @Override
    public void onClick(View v) {
        autoCompleteTextView.setText(" ");
        searchAdapter.notifyDataSetChanged();
        autoCompleteTextView.showDropDown();
    }
};

Upvotes: 5

Views: 7248

Answers (1)

serenskye
serenskye

Reputation: 3467

Fixed using this answer on SO

Basically override AutoCompleteTextView onFocusedChanged

@Override
protected void onFocusChanged(boolean focused, int direction,
                              Rect previouslyFocusedRect) {
    super.onFocusChanged(focused, direction, previouslyFocusedRect);
    if (focused) {
        performFiltering(getText(), 0);
    }
}

Upvotes: 2

Related Questions