Я пытаюсь реализовать настраиваемое представление поиска в android, изображение прикреплено внизу:
Итак, я разработал свое меню следующим образом:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_search"
android:icon="@drawable/search"
android:orderInCategory="100"
android:title="@string/search_allover"
android:actionLayout="@layout/home_search_view"
app:actionViewClass="androidx.appcompat.widget.SearchView"
app:showAsAction="collapseActionView|ifRoom" />
</menu>
И ActionLayout вот так:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Spinner
android:layout_width="100dp"
android:layout_height="wrap_content"
android:entries="@array/home_search_item" />
<SearchView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:background="#FFFFFF"
android:queryHint="Let us help with you're looking" />
</LinearLayout>
И я определил String-Array в строке:
<string-array name="home_search_item">
<item>Everywhere</item>
<item>Course Name</item>
<item>Course Code</item>
<item>Instructor</item>
<item>Representative</item>
<item>Percentage</item>
</string-array>
Но счетчик никогда не появляется, я думаю, ActionLayout не вызывается. как подсказка запроса говорит: "Поиск" вместо предоставленного мной текста.
android настраиваемый вид поиска