gpt4 book ai didi

java - 该 Activity 已经有一个由窗口装饰提供的操作栏。

转载 作者:行者123 更新时间:2023-12-02 11:52:10 25 4
gpt4 key购买 nike

当我尝试启动我的应用程序时,出现此异常,为什么?

Do not request Window.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.

STYLES.XML

    <!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>

</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

</resources>

有人可以帮助我吗?

谢谢

最佳答案

该错误表明您的 Activity 不支持 Window.FEATURE_SUPPORT_ACTION_BAR

因此您可以在 Activity 布局中使用工具栏

这里是Good Example为此。

此外,您需要在 Manifest 中正确设置 activity 主题。

用途:

<activity 
android:name=".activity.YourActivity" //the activity where you got the crash
android:theme="@style/AppTheme.NoActionBar"> //add this

关于java - 该 Activity 已经有一个由窗口装饰提供的操作栏。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47816482/

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