As the title suggests I want to create a custom title bar for a PreferenceAcitvity
.
I need to add a summary below the title. Currently it will only display a title, but I need a sub-title, just like any Preference
can have a summary.
I have read loads of questions here, like this and this, but these all do something different; it's not possible to include a summary for the title with the first method. Creating a custom layout for every Preference
also doesn't seem the wisest option, and is loads of meaningless work (I have tons of PreferenceActivity
's. I am looking into extending something.
Also, I want to keep the default behaviour as much as possible, so I am looking into ways of adding a TextView
to the default layout located in android-sdk-windows\platforms\android-16\data\res\layout\screen_title.xml
So I thought I would apply this layout to the method in the second Q, but now I run into the problem of resource id's used in the screen_title.xml file that aren't public.
I'm running out of ideas...anyone got some fresh ones?
EDIT:
I found a solution thanks to the accepted answer below.
To clarify a bit further: the method getSupportActionBar()
in the answer isn't in the SDK, but comes from ActionBarSherlock
.
This is a compatibility library to enable the ActionBar
and FragmentActivity
(amongst other things) on pre API 11 applications/ devices. It's quite a heavy library, around 11mb, so you will have to think about if it's worth adding 11mb to your application just to have a summary/ subtitle in your preference screen's. On the other hand, this ofcourse also allows you to implement the other features of the library, such as actually creating an action bar (and or menu).