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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:52:28+00:00 2026-05-27T15:52:28+00:00

In my application I am using the new Action Bar Compatibility sample from Google

  • 0

Example: Android Market

In my application I am using the new Action Bar Compatibility sample from Google (located at <sdk>/samples/android-<version>/ActionBarCompat) which works great. The only problem I have is applying this to my PreferenceActivity in order to get a screen like the settings in the Android Market (see picture).

To fill the ActionBar with icons, each Activity must extend the ActionBarActivity class. The problem is that my Activity already extends PreferenceActivity and in Java classes can not extend more than one class.

There must be a way to get the ActionBar together with a PreferenceScreen. I would be glad if anybody could provide a solution for this common issue.

P.S.: A solution like in How to add a button to PreferenceScreen does not fit because the ActionBar is actually the title bar and so this is more a Java than a layout thing.

  • 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-05-27T15:52:29+00:00Added an answer on May 27, 2026 at 3:52 pm

    Edit: My answer below is rather hacky and it seems like it is now outdated (for pre Android 3.0) Have a look at the other answers for less hacky and more current solutions ~pyko 2014-09-01


    I managed to get it working – not sure if this is the nicest/cleanest solution, but it works.

    Had to make the following changes:

    1. Make a copy of ActionBarActivity and have the new class extend PreferenceActivity

      public abstract class ActionBarPreferenceActivity extends PreferenceActivity {
          // contents exactly the same as 'ActionBarActivity'
      }
      
    2. Modify onCreate() in ActionBarHelperBase.java slightly – make a special case for PreferenceActivity classes

      @Override
      public void onCreate(Bundle savedInstanceState) {
          // If the activity is a PreferenceActivity, don't make the request
          if (!(mActivity instanceof PreferenceActivity)) {
              mActivity.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
          }
      
    3. Have your PreferenceActivity extend this class and add request for FEATURE_CUSTOM_TITLE before you call super.onCreate()

      public class MyPreferenceActivity extends ActionBarPreferenceActivity {
      
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); // add this line
              super.onCreate(savedInstanceState);
              addPreferencesFromResource(R.xml.preferences);
              // etc etc
          }
      
          // etc etc
      }
      

    As far as I can tell, changes 2 and 3 are needed because for PreferenceActivity:

    “As soon as you call super.onCreate(), the ViewGroup will be set up and so, you are not allowed to change the Window’s parameters.” (see Oliver’s comment to the answer)

    I guess the order of how components in PreferenceActivity activities are created is different to plain Activity activities .

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

Sidebar

Related Questions

I am writing a new application using the Entity Framework. Where would the EF
I have been building a new application using my current understanding of domain driven
I want to create a new business application using the Django framework. Any suggestions
we are currently working on a new web application using Java and MySql. We
I am new to Swing. I am trying to develop an application using Swing.
I have built a very simple blog application using Ruby on Rails. New to
I'm trying to start a new ASP.NET Web Application Project using Visual Studio 2008.
I'm using VS2008 to debug an application that starts a new process. I believe
I am using the webapplicationbuilder class to create a new web application and have
I'm starting a new application and looking at using an ORM -- in particular,

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.