5

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();
    }
};
serenskye
  • 3,467
  • 5
  • 35
  • 51
  • what is onAutoCompleteClickListener for? and how do you load the data? – pskink May 29 '14 at 16:28
  • that's a listener for when you click on the AutoCompleteTextView. The data is loaded asynchronously - it loads fine and it's set on the adapter before the textview is clicked. It just i have to click on the textview twice before I can see the drop down – serenskye May 30 '14 at 08:43
  • see my answer here http://stackoverflow.com/questions/19858843/how-to-dynamically-add-suggestions-to-autocompletetextview-with-preserving-chara – pskink May 30 '14 at 08:46
  • Sorry I don't understand how that helps – serenskye May 30 '14 at 08:52
  • I don't understand which particular bit of your answer fixes my problem? Your answer shows loading data, using a FilterQueryProvider, I don't use or need cursors and my data loading works. – serenskye May 30 '14 at 08:57
  • did you notice how simple it is? just modify runQuery and you're done – pskink May 30 '14 at 09:00
  • I haven't noticed how simple it is because I still don't see how this answers the original issue in the question, how it solves the problem. If you can't explain why and how your solution works, you can't expect me to use it. I have now found a solution. – serenskye May 30 '14 at 09:02
  • No - you miss the point, I can't use a solution if it is not explained properly - if you have a correct answer that could solve the problem please answer in the answers section, not in the comments with a full explanation and if it works I will mark as correct answer – serenskye May 30 '14 at 09:14
  • you said you load the data asynchronously, you use showDropDown(), they seem to be some workarounds, you seem not to use the mechanisms that are built in the framework like android.widget.Filter, see the docs for more info, and the easiest filtering is done in CursorAdapter hence i use FilterQueryProvider – pskink May 30 '14 at 09:47
  • Hi, if you have a solution please answer. I am using a Filter. I have the data as I said - I just can't get the dropdown to show. I don't want to use this as a discussion forum, if you have an answer please provide one. – serenskye May 30 '14 at 10:12

1 Answers1

2

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);
    }
}
Community
  • 1
  • 1
serenskye
  • 3,467
  • 5
  • 35
  • 51