I’m trying to create a TextView in the menu, the text is to be set dynamically. Right now my menu has this:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/action_search"
android:actionViewClass="android.widget.SearchView"
android:icon="@android:drawable/ic_menu_search"
android:showAsAction="ifRoom"
android:title="Search"/>
<item
android:id="@+id/action_sync"
android:icon="@drawable/ic_menu_refresh"
android:showAsAction="ifRoom"
android:title="Sync"/>
</menu>
How can I create an item which has only text?
If you want to just show text, simply don’t add an icon in menu.xml. If you want to change the text in code, you can do so in the onPrepareOptionsMenu() on your activity callback as such: