Search code examples
androidandroid-actionbarandroid-menuandroid-optionsmenuandroid-icons

How to change option menu icon in the action bar?


How to change the index icon of option menu?

enter image description here

I mean icon (3).

Here is my code:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.options, menu);

    return true;
}

And here is the XML file:

<item android:id="@+id/Bugreport"
    android:title="@string/option_bugreport" />

<item android:id="@+id/Info"
    android:title="@string/option_info" />

<item android:id="@+id/About"
    android:title="@string/option_about" />


Solution

  • The following lines should be updated in app -> main -> res -> values -> Styles.xml

     <!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
        <item name="android:actionOverflowButtonStyle">@style/MyActionButtonOverflow</item>
    </style>
    
    <!-- Style to replace actionbar overflow icon. set item 'android:actionOverflowButtonStyle' in AppTheme -->
    <style name="MyActionButtonOverflow" parent="android:style/Widget.Holo.Light.ActionButton.Overflow">
        <item name="android:src">@drawable/ic_launcher</item>
        <item name="android:background">?android:attr/actionBarItemBackground</item>
        <item name="android:contentDescription">"Lala"</item>
    </style>
    

    This is how it can be done. If you want to change the overflow icon in action bar