Search code examples
androidxmlactionbarsherlock

Show Only Text as MenuItem in ActionBar


I've been searching for a way to add text as a MenuItem to the ActionBar. I've tried setting the icon to a transparent ColorDrawable and showAsAction withText but nothing seems to work. Is there any way to add text as a MenuItem?

Thanks for any help :)


Solution

  • If you don't specify the android:icon of the menu item, it will default to the android:title given by you in the XML file.

    Try this and replace the android:id and android:title accordingly:

    <item
        android:id="@+id/menu_item_id"
        android:showAsAction="always"
        android:title="@string/menu_item_title"/>
    

    Hope that helps!