2

I am using a custom title bar for my all activities but i can use this in PreferenceActivity. All i can do in PreferenceActivity is this:

    @Override
protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_bar);
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences3);

My title bar in preference activity stay always grey without any text but other activities works very well this code. What i can do to solve my problem??

Vítor Nóbrega
  • 1,219
  • 4
  • 26
  • 53

1 Answers1

3

put getWindow().... after super and addPreferencesFromResource... so order should be:

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences3);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_bar);

p.s. credits to original author @jeffrey-blattman following my previous answer here..

Community
  • 1
  • 1
Ewoks
  • 12,285
  • 8
  • 58
  • 67