I'm using Android Support Library AppCompat
for my app, and I try to add Search Widget
into my view. Firstly, I meet a very frustrated error, that Search Widget is not appear on screen. Here is the menu xml file :
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_example"
android:title="@string/action_example"
app:showAsAction="withText|ifRoom" />
<item android:id="@+id/search_bar"
android:title="@string/search_title"
android:icon="@drawable/ic_menu_search"
android:showAsAction="always" (LINE ONE)
android:actionViewClass="android.support.v7.widget.SearchView"/> (LINE TWO)
</menu>
After hours for debugging. I have noticed error and change to below xml file:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_example"
android:title="@string/action_example"
app:showAsAction="withText|ifRoom" />
<item android:id="@+id/search_bar"
android:title="@string/search_title"
android:icon="@drawable/ic_menu_search"
app:showAsAction="always" (LINE ONE)
app:actionViewClass="android.support.v7.widget.SearchView"/> (LINE TWO)
</menu>
As you notice that there is just a slight difference at LINE ONE
and LINE TWO
that I change android
to app
. That works magically. But, I don't know what difference behind that two lines. what difference and meaning when we declare:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
I have google but no post relates to my problem and question.
Thanks :)