Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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() {

This comment has been minimized.

Copy link

@GyyBest 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
You can’t perform that action at this time.