Skip to content

Instantly share code, notes, and snippets.

@javier-delgado
Last active August 30, 2017 14:03
Show Gist options
  • Save javier-delgado/29886c5ead02c8dd4808 to your computer and use it in GitHub Desktop.
Save javier-delgado/29886c5ead02c8dd4808 to your computer and use it in GitHub Desktop.
Instant autocompleteTextView for android
public class InstantAutoComplete extends AutoCompleteTextView {
public InstantAutoComplete(Context context) {
super(context);
}
public InstantAutoComplete(Context arg0, AttributeSet arg1) {
super(arg0, arg1);
}
public InstantAutoComplete(Context arg0, AttributeSet arg1, int arg2) {
super(arg0, arg1, arg2);
}
@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(getText(), 0);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment