gpt4 book ai didi

android Activity 首先调用requestWindowFeature并显示标题

转载 作者:行者123 更新时间:2023-11-30 03:22:42 24 4
gpt4 key购买 nike

我的 Activity 使用了一个设置 android:windowNoTitle = true 的主题。但是我必须在一些 Activity 中显示标题。我想通过调用 requestWindowFeature() 在我的 Activity 中显示标题,但它不起作用!任何帮助都会很棒。

谢谢。

附言:我的 Activity 必须在两个主题之间切换。homeActivty 使用操作栏,其他 Activity 没有标题。这些 Activity 使用相同的主题。所以在使用 requestWindowFeature() 之前它一直被隐藏,我现在只想显示它。

这是我的代码:定义的主题:

    <!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">

<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="android:windowAnimationStyle">@style/activityAnimation</item>
<item name="android:windowNoTitle">true</item>
<!-- <item name="android:background">@color/background_holo_light</item> -->
</style>

并在应用中使用主题:

    <application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >

必要时获取和更改主题:

int mThemeId = mSettingPreferences.getInt(MySettings.THEME_ID, -1);
if (-1 != mThemeId) {
this.setTheme(mThemeId);
}
// do something to show the title

最佳答案

this.requestWindowFeature(Window.FEATURE_NO_TITLE);

setContentView(R.layout.yourlayout);

如果您使用它,则无需应用任何主题

关于android Activity 首先调用requestWindowFeature并显示标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18821563/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com