问题
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??
回答1:
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..
来源:https://stackoverflow.com/questions/6803707/custom-title-bar-in-preferenceactivity