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

  • SEARCH
  • Home
  • 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 9135887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:52:51+00:00 2026-06-17T08:52:51+00:00

Is it possible on Android to have MenuItems (either the ones from the options

  • 0

Is it possible on Android to have MenuItems (either the ones from the options menu hardware key or action bar — they are the same anyways) with different styles?

I want one to have a selector applied and another with different selector.

From my search online, I found that you can change the theme and override an attribute with your own style, but that applies to ALL MenuItems.

Can I still set the android:background property in XML?

  • 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-17T08:52:52+00:00Added an answer on June 17, 2026 at 8:52 am

    It is possible for items of the ActionBar. You have to define the item that you want to have a different selector as a custom action view.

    <item
        android:id="@+id/menu_custom"
        android:actionLayout="@layout/action_view"
        android:showAsAction="always"/> 
    

    In the layout referenced by android:actionLayout you have an ImageView that you assign your selector and make it clickable and focusable.

    <ImageView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/action_view_background"
        android:clickable="true"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:minWidth="56dip"
        android:paddingBottom="8dip"
        android:paddingTop="8dip"
        android:src="@drawable/ic_launcher" />
    

    The click event is not handled by onOptionsItemSelected. You have to attach an OnClickListener in onCreateOptionsMenu.

    menu.findItem(R.id.menu_custom).getActionView().setOnClickListener(l);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible with Android to have a search bar for a ListView so
Possible Duplicate: Detect multitouch with Ontouch listener Android I have a question about detecting
Possible Duplicate: How to convert MDB to SQLite in Android I have an MS
Is it possible to have a Android VNC server compiled lib inside my android
Is it possible to develop android games and application if we have good knowledge
Possible Duplicate: Can I scroll a ScrollView programmatically in Android? I have a chat
Is it possible to programmatically create VPN profile on Android (assuming that I have
Possible Duplicate: Is there a way to automatically update application on Android? I have
i have a stupid question. Its possible to export JavaFX2 to Android. I have
I would use Jmagick into an Android Project. Is it possible? I have to

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.