I've got this problem but the thing is that I do have a title
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/tools">
<!-- Search, should appear as action button -->
<item
android:title="@string/action_search"
android:id="@+id/action_search"
android:icon="@drawable/ic_action_search"
android:showAsAction="ifRoom" />
<item
android:title="@string/action_settings"
android:id="@+id/action_settings"
android:showAsAction="never" />
</menu>
in the strings xml file i did the strings, the program even switches the action_search and action_settings with its string - search and settings.
Just a wrong XML namespace! Try with:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
</menu>
And as G.T. suggested you should consider using appcompat on the showAsAction property (only needed if you want to support API < 11):
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/item1"
android:icon="@drawable/ic_launcher"
app:showAsAction="ifRoom|withText"
android:title="@string/Add_New" />
</menu>
Note:
The appcompat library is compatible with some old Android versions (API 7+) that can't handle the showAsAction property because they don't have the ActionBar (API < 11).
can you remove those things xmlns:android="schemas.android.com/apk/res-auto"; xmlns:android="schemas.android.com/tools";
Also try to follow Goolge dev examples here http://developer.android.com/guide/topics/ui/menus.html
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/new_game"
android:icon="@drawable/ic_new_game"
android:title="@string/new_game"
android:showAsAction="ifRoom"/>
<item android:id="@+id/help"
android:icon="@drawable/ic_help"
android:title="@string/help" />
</menu>
It actually need a namespace to identify the process.
<?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_shuffle"
android:icon="@drawable/android_music_player_rand"
android:orderInCategory="1"
app:showAsAction="always"
android:title="Shuffle"
android:onClick="shuffle"/>
<item
android:id="@+id/action_end"
android:icon="@drawable/end"
android:orderInCategory="2"
app:showAsAction="always"
android:title="End"
android:onClick="end"/>
</menu>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With