21

I wanna change the three dots button on Android to other button which is an "Add" button. How to do it? I have changed set the button in my drawable, but it keep prompt the three dot button.

Thanks

Darek Kay
  • 15,827
  • 7
  • 64
  • 61
chemat92
  • 501
  • 2
  • 7
  • 16
  • 1
    If you paste your code someone may be able to help you faster. – Sameer Khan May 15 '15 at 20:17
  • Please add some picture here what do want to achieve. Then you will get help faster. Because what you said is very difficult to understand. – Omar Faroque Anik May 15 '15 at 20:34
  • Possible duplicate of [How to change option menu icon in the action bar?](https://stackoverflow.com/questions/26300480/how-to-change-option-menu-icon-in-the-action-bar) – NNN Jun 23 '17 at 07:52

6 Answers6

38

Sorry i can't reply as a comment, but i'm guessing you want to change the actionbar overflow menu icon. If so you can do it in 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>
</style>

Original post: How to change option menu icon in the action bar?

Community
  • 1
  • 1
Lalsangpuia Ralte
  • 611
  • 1
  • 7
  • 7
17

Sorry I don't have enough reputation to post a comment. Here is the best answer I found, its one line of code:

myToolbar.setOverflowIcon(ContextCompat.getDrawable(getApplicationContext(),R.drawable.my_drawable));

The link for the original answer is here: https://stackoverflow.com/a/35790470/4575772

NNN
  • 543
  • 5
  • 14
  • 1
    Please don't post link only answers to other Stack Overflow questions. Instead, vote/flag to close as duplicate, or, if the question is not a duplicate, *tailor the answer to this specific question.* – Paul Roub Jun 22 '17 at 21:05
11

If you want to add other icon instead of 3 dots then just create menu.xml like below code:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<item android:id="@+id/menu_item_add"
    android:title="Add"
    app:showAsAction="always"
    android:icon="@drawable/ic_add" />
</menu>

Note: Don't use android:showAsAction. Use app:showAsAction.

Darsh Patel
  • 1,015
  • 9
  • 15
7
//just edit menu.xml file    
//add icon for item which will change default setting icon
//add sub menus


 ///menu.xml file


    <item
            android:id="@+id/action_settings"
            android:orderInCategory="100"
            android:title="@string/action_settings"
            android:icon="@drawable/your_icon"
            app:showAsAction="always" >

            <menu>

                <item android:id="@+id/action_menu1"
                    android:icon="@android:drawable/ic_menu_preferences"
                    android:title="menu setting" />

                <item android:id="@+id/action_menu2"
                    android:icon="@android:drawable/ic_menu_help"
                    android:title="help" />

            </menu>
        </item>
Aditya varale
  • 447
  • 8
  • 6
4

hope this help u, just set your xml menu like this:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:icon="@drawable/your_icon"
        android:title="menu"
        app:showAsAction="always">
        <menu>

            <item
                android:id="@+id/action_menu1"
                android:orderInCategory="1"
                android:title="menu 1" />

            <item
                android:id="@+id/action_menu2"
                android:orderInCategory="2"
                android:title="menu 2" />

        </menu>
    </item>
</menu>
IRvanFauziE
  • 823
  • 11
  • 16
1

For those who use Kotlin:

toolbar.overflowIcon = ContextCompat.getDrawable(applicationContext,android.R.drawable.ic_dialog_info)

Note: "ic_dialog_info" is an icon example.

Franco Rojas
  • 91
  • 2
  • 4