Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7959593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:35:53+00:00 2026-06-04T04:35:53+00:00

Whilst I can set Action Bar icons in my Java code, I’m unable to

  • 0

Whilst I can set Action Bar icons in my Java code, I’m unable to get them to display when I set them in my XML. I’d prefer set them in XML.

Below are my two attempts to achieve the same thing – three icons on the Action Bar. Could you explain why the second approach fails?

(Note, In my final version, I’m intending to keep two of the three in the overflow menu, I’m just trying to show all three during testing.)

This XML:

<?xml version="1.0" encoding="utf-8"?>
    <menu xmlns:android="http://schemas.android.com/apk/res/android">
        <item   android:id="@+id/menuConfig"
                android:title="Configuration"
        />
        <item   android:id="@+id/menuAbout"
                android:title="About" 
        />
        <item   android:id="@+id/menuHelp"
                android:title="Help" 
        />
    </menu>

And this Java:

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

    MenuItem settings = menu.findItem(R.id.menuConfig);     
    settings.setIcon(R.drawable.settings);
    settings.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    MenuItem about = menu.findItem(R.id.menuAbout);     
    about.setIcon(R.drawable.about);
    about.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    MenuItem help = menu.findItem(R.id.menuHelp);       
    help.setIcon(R.drawable.help);
    help.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    return true;
}   

Produce this display:

enter image description here

Whereas, this XML:

<?xml version="1.0" encoding="utf-8"?>
    <menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item   android:id="@+id/menuConfig"
            android:title="Configuration"
            android:icon="@drawable/settings"
            showAsAction="ifRoom"
    />
    <item   android:id="@+id/menuAbout"
            android:title="About" 
            android:icon="@drawable/about"
            showAsAction="ifRoom"
    />
    <item   android:id="@+id/menuHelp"
            android:title="Help" 
            android:icon="@drawable/help"
            showAsAction="ifRoom"
    />
</menu>

And this Java:

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

    return true;
}   

Produce this display:

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:35:54+00:00Added an answer on June 4, 2026 at 4:35 am

    That’s ok.

    The overflow menu only shows text. The icons are only used when the Item is shown in the action bar as an action.

    If you want to see the icons in the action bar you have to use

    android:showAsAction="ifRoom"
    

    instead of

    showAsAction="ifRoom"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I get access to the iPhone clipboard whilst using PhoneGap? I cannot
Okay so I've been set an assignment from university and I just can't get
I am using symfony 1.0.6 and in action file we can set error using,
Whilst inside an iframe, can you please let me know how I can obtain
Can you remove an item from a List<> whilst iterating through it? Will this
Whilst working on some generally horrible Javascript code this morning, I came across the
I've just written a piece of code to display a UIActionSheet within my app.
I want to gather a fairly complicated wrapped set using JavaScript whilst avoiding having
Given that <select> and <textarea> display as two different widths if both set to
Awkward title I know, this is best explained in code. Given a set of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.