There is a moment in my app, that I need to force to show all items in the suggestion list, no matter what the user has typed. How can I do that?
I tried to do somet
If you want to show the suggestions instantly, then you have to override enoughToFilter() to make it always return true. To ignore what is given as text input, you have to use performFiltering("", 0) with an empty filtering pattern. The AutoCompleteTextView then shows all suggestions.
This is solution I've combined from other StackOverflow posts:
public class InstantAutoComplete extends android.support.v7.widget.AppCompatAutoCompleteTextView {
public InstantAutoComplete(Context context) {
super(context);
}
public InstantAutoComplete(Context context, AttributeSet attrs) {
super(context, attrs);
}
public InstantAutoComplete(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public boolean enoughToFilter() {
return true;
}
@Override
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
super.onFocusChanged(focused, direction, previouslyFocusedRect);
if (focused && getAdapter() != null) {
performFiltering("", 0);
}
}
}