我有以下代码导致错误消息,我*无法将 FEATURE_CUSTOM_TITLE 与其他标题功能结合*(据我所知...)
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String customTitleStr = getIntent().getExtras().getString("Title");
Boolean customTitleSupported = this.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
if ( (customTitleSupported) && (customTitleStr != null) ) {
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.override_titlebar);
final TextView myTitleText = (TextView) findViewById(R.id.myTitleText);
if ( myTitleText != null ) {
myTitleText.setText(customTitleStr);
}
}
我试过地方setContentView(R.layout.); this.requestWindowFeature之前和之后都没有变化。
我的清单针对的是:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17"
/>
供参考(不知道是否相关),我也无法主题化我的标题栏。(直接忽略。)
以防万一,我的主题的一些代码片段:
AndroidManifest.xml:
<application
android:allowBackup="true"
android:icon="@drawable/replace__logo__app_android"
android:label="@string/MicAppName"
android:theme="@style/MicTheme"
android:name="com.examples.example.MicApp"
>
样式.xml:
<style name="AppBaseTheme" parent="android:Theme.Light">
</style>
<style name="AppTheme" parent="AppBaseTheme">
</style>
// ...
<style name="MicTheme" parent="AppTheme">
<item name="android:windowTitleSize">44dip</item>
<item name="android:windowTitleBackgroundStyle">@style/MicWindowTitleBackground</item>
<item name="android:windowTitleStyle">@style/MicWindowTitle</item>
</style>