Skip to content

Instantly share code, notes, and snippets.

Created September 7, 2015 12:36
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ruuhkis/d942330d97163d868ee7 to your computer and use it in GitHub Desktop.
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
import android.widget.AutoCompleteTextView;
* Created by PasiMatalamaki on 7.9.2015.
public class InstantAutoCompleteTextView extends AutoCompleteTextView {
private boolean showAlways;
public InstantAutoCompleteTextView(Context context) {
public InstantAutoCompleteTextView(Context context, AttributeSet attrs) {
super(context, attrs);
public InstantAutoCompleteTextView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
public InstantAutoCompleteTextView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
public void setShowAlways(boolean showAlways) {
this.showAlways = showAlways;
public boolean enoughToFilter() {
return showAlways || super.enoughToFilter();
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
super.onFocusChanged(focused, direction, previouslyFocusedRect);
private void showDropDownIfFocused() {
if (enoughToFilter() && isFocused() && getWindowVisibility() == View.VISIBLE) {
protected void onAttachedToWindow() {
Copy link

GyyBest commented May 31, 2017

How to use it, please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment