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 9307641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T00:26:17+00:00 2026-06-19T00:26:17+00:00

I have an app, which have toggle button in action menu item, though i’m

  • 0

I have an app, which have toggle button in action menu item, though i’m using Actionbar Sherlock, I don’t know, how to place the toggle button in the action menu item. I don’t want to place as a custom layout in action bar, but i want to place it as a Menu item. If anyone find solution, Please help me out.

Purpose, If I change the state of toggle button, it will sort the person based on ALphabets and again in Date of Birth.

Thanks in Advance!

  • 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-19T00:26:19+00:00Added an answer on June 19, 2026 at 12:26 am

    Just add it like a normal Menu Button, check its state with a boolean variable, and you can change the icon and title when changing the sortmode

    boolean birthSort=false;
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case R.id.menu_toggle:
    
            if(birthSort){
                //change your view and sort it by Alphabet
                item.setIcon(icon1)
                item.setTitle(title1)
                birthSort=false;
            }else{
                //change your view and sort it by Date of Birth
                item.setIcon(icon2)
                item.setTitle(title2)
                birthSort=true;
            }
            return true;
    
    
    
        }
        return super.onOptionsItemSelected(item);
    
    
    }
    

    Don’t forget to add it in xml like any other menu button and configure android:showAsAction if you want to show it in overflow or outside of it.

    <menu xmlns:android="http://schemas.android.com/apk/res/android">
    
    <item android:id="@+id/menu_toogle"
        android:showAsAction="ifRoom"
        android:title="Share"
         />
    </menu>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an app, which on button (toggle button) press scans and displays discovered
I have a app which will download a file from web. The download action
In my c# winform app I have a button which when clicked, it performs
I am working on WPF app in which I have a textbox, Button, Label
I have a WebServerService which I would like to start when a toggle button
i have a toggle button which when set to the on position sets the
I have app in which i have recorded sound files i want that i
I have an app which has a map and some POI on it. I'm
I have an app which contain some images in res/drawable/ and shows them in
I have an app which access an app folder on a per user basis.

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.