MultiAutoCompleteTextView does not invoke onFocusChanged()

86 views Asked by At

In need to do some stuff when the MultiAutoCompleteTextView gets tapped and gain focus but it seems that the listener does not get invoked. Any idea why? Here's the code:

searchbar.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean b) {
            if(b) hide();
            else Utils.closeKeyboard(MapsActivity_v2.this, view);
        }
    });

<MultiAutoCompleteTextView
                android:imeOptions="actionDone"
                android:id="@+id/searchbar"
                android:focusable="true"
                android:focusableInTouchMode="true"
                android:background="@android:color/transparent"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:hint="@string/search_hint"
                android:padding="6dp"/>
1

There are 1 answers

2
Zafar Kurbonov On BEST ANSWER

Add in XML:

android:focusable="true"
android:focusableInTouchMode="true"

Code is working correctly.