-
-
Save furycomptuers/4961368 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import android.graphics.Rect; | |
import android.util.AttributeSet; | |
import android.util.Log; | |
import android.view.View; | |
import android.widget.AutoCompleteTextView; | |
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 (getWindowVisibility() == View.GONE) { | |
Log.d("InstantAutoComplete", "Window not visible, will not show drop down"); | |
return; | |
} | |
if (focused) { | |
performFiltering(getText(), 0); | |
showDropDown(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This silently ignores the situation when focus gets restored on configuration change. I've ended up using
View#post
: