androidmultiautocompletetextview

MultiAutoCompleteTextView does not invoke onFocusChanged()


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"/>

Solution

  • Add in XML:

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

    Code is working correctly.