Skip to content

Instantly share code, notes, and snippets.

@JSBerrocoso
Created July 2, 2015 10:19
Show Gist options
  • Save JSBerrocoso/9cf3c03aed06d1bc0076 to your computer and use it in GitHub Desktop.
Save JSBerrocoso/9cf3c03aed06d1bc0076 to your computer and use it in GitHub Desktop.
package com.atomic.android.utils.views;
import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.AutoCompleteTextView;
/**
* Created by J. Santiago Berrocoso on 2/7/15.
* Atomic Internet S.L.
* [email protected]
*/
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