MultiAutoCompleteTextView не вызывает onFocusChanged()

При необходимости сделать что-то, когда MultiAutoCompleteTextView нажимается и получает фокус, но кажется, что слушатель не вызывается. Есть идеи, почему? Вот код:

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

person Lamberto Basti    schedule 01.09.2017    source источник


Ответы (1)


Добавьте в XML:

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

Код работает корректно.

person Zafar Kurbonov    schedule 01.09.2017
comment
родительский макет LinearLayout ?? - person Zafar Kurbonov; 01.09.2017
comment
Относительный макет - person Lamberto Basti; 01.09.2017