0

I am having difficulty adding an extra icon (the ic_launcher is added in the styles.xml; there is no menu.xml) to the ActionBar. I have added a dropdown which works fine (the 3 dots), but if I use the following code the "Item" text is added to this and not the ActionBar (the icon appears nowhere).

 private void CreateMenu(Menu menu) {
    MenuItem mnu1 = menu.add(0,0,0,"Item"); {
       mnu1.setIcon(R.drawable.ic_newicon);
    }

 public boolean onCreateOptionsMenu(Menu menu) {   //--- Everything in the dropdown works fine --
    getMenuInflater().inflate(R.menu.activity_main_actions, menu);     //--- The dropdown menu --
    return super.onCreateOptionsMenu(menu);
    ...
 }

I am obviously missing something simple here. Can anyone assist please?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Archdeacon
  • 193
  • 1
  • 4
  • 15

1 Answers1

0

try this

Drawable drawable = ContextCompat.getDrawable(getApplicationContext(),R.drawable.yourDrawable);
    toolbar.setOverflowIcon(drawable);

for other options check out following links link1

link2

akshay_shahane
  • 4,423
  • 2
  • 17
  • 30
  • Problem solved. I had simply omitted "android:showAsAction="always" from the xml file so it now works OK. Thanks again. – Archdeacon Aug 07 '17 at 15:02