Skip to content

Instantly share code, notes, and snippets.

@logcat
Forked from furycomptuers/InstantAutoComplete
Last active August 29, 2015 14:27
Show Gist options
  • Save logcat/8e1f5acd07502bcc08ef to your computer and use it in GitHub Desktop.
Save logcat/8e1f5acd07502bcc08ef to your computer and use it in GitHub Desktop.
import android.content.Context;
import android.graphics.Rect;
import android.support.v7.widget.AppCompatAutoCompleteTextView;
import android.util.AttributeSet;
import android.view.View;
public class InstantAutoCompleteTextView extends AppCompatAutoCompleteTextView {
public InstantAutoCompleteTextView(Context context) {
super(context);
}
public InstantAutoCompleteTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public InstantAutoCompleteTextView(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 (getWindowVisibility() == View.GONE) {
return;
}
if (focused && getAdapter() != null) {
performFiltering(getText(), 0);
showDropDown();
}
}
@Override
public boolean performClick() {
showDropDown();
return super.performClick();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment