Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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" /> 

like image 827
smartmouse Avatar asked Oct 10 '14 13:10

smartmouse


People also ask

How will you replace a menu with the action bar?

To replace an app's default action bar with a Toolbar : Create a new custom theme and modify the app's properties so that it uses this new theme. Disable the windowActionBar attribute in the custom theme and enable the windowNoTitle attribute. Define a layout for the Toolbar .

What are action bar icons?

The ActionBar, now known as the App Bar, is a consistent navigation element that is standard throughout modern Android applications. The ActionBar can consist of: An application icon. An "upward" navigation to logical parent.


1 Answers

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

like image 113
Syed Raza Mehdi Avatar answered Sep 22 '22 13:09

Syed Raza Mehdi