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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:40:50+00:00 2026-06-16T01:40:50+00:00

I apply a custom View to the ActionBar , like this // Inflate the

  • 0

I apply a custom View to the ActionBar, like this

// Inflate the "Done/Discard" custom ActionBar view.
LayoutInflater inflater = (LayoutInflater) DetailsHost.mActionBar
        .getThemedContext().getSystemService(DetailsHost.LAYOUT_INFLATER_SERVICE);
final View customActionBarView = inflater.inflate(
        R.layout.actionbar_custom_view_done_discard, null);

// Show the custom ActionBar view and hide the normal Home icon and title.
DetailsHost.mActionBar.setDisplayOptions(
        ActionBar.DISPLAY_SHOW_CUSTOM,
        ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME
                | ActionBar.DISPLAY_SHOW_TITLE);
DetailsHost.mActionBar.setCustomView(customActionBarView, 
        new ActionBar.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));

(based on Roman Nuriks code).

How do I restore the initial layout? Note: I use ActionBarSherlock

  • 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-16T01:40:51+00:00Added an answer on June 16, 2026 at 1:40 am

    Show/hide custom actionbar view

    Since you only added a custom view to the bar without removing the title it should be sufficient to hide that custom View. You can use method setDisplayShowCustomEnabled(). Just call:

    getActivity().getActionBar().setDisplayShowCustomEnabled(false);
    

    And enable home functionality again:

    getActivity().getActionBar().setDisplayShowHomeEnabled(true);
    

    (Note in all code examples use getSupportActionBar() instead of getActionBar() if you’re using actionbar compat. Also the getActivity() is only needed from fragments, in activities refer to the activity itself, in most cases this)

    Restore actionbar title

    If however you also removed the title when creating your custom view you’ll have to enable that again also.

    getActivity().getActionBar().setDisplayShowTitleEnabled(true);
    

    Restore completely

    You can also call the setDisplayOptions() method with a combination of options to reconfigure the actionbar in one call. The below example removes the custom view and shows the title.

    getActivity().getActionBar().setDisplayOptions(
        ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE);
    

    See Android API docs for more details on these options.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was able to make custom toast using this code LayoutInflater inflater = getLayoutInflater();
I am not able to apply onclick event in global custom text field. This
I have a few custom form validation rules I wish to apply. Things like
Is there a way to apply a custom order to the Select A View
I have a custom style that I would like to apply to my views.
This use case seems like it would apply to just about every form, but
I have created a custom view to draw a line on the screen. This
I have a Knockout.js view model that looks like this: UserName:null, FirstName:null, LastName:null, Countries:{
I am using apple's custom table view cell code and modifying the drawRect code
General approach in GWT is to use Panels and then apply custom CSS themes

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.