繁体   English   中英

使用NoActionBar时出现AppCompat主题错误

[英]AppCompat Theme Error when using NoActionBar

我正在为整个应用程序使用工具栏。 因此,我将应用程序主题设置为Theme.AppCompat.Light.NoActionBar,但是我需要在应用程序的一部分中显示一个警告对话框。 当我尝试显示警报对话框时,出现有关Theme.Appcompat的运行时错误

在此处输入图片说明

我的manifest.xml文件

<application
    android:allowBackup="true"
    android:icon="@drawable/app_icon2"
    android:label="@string/app_name"
    android:theme="@style/Theme.AppCompat.Light.NoActionBar"
    >
    <activity
        android:name="com.project.project.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.project.project.StActivity"
        android:configChanges="orientation|screenSize|keyboardHidden"
        android:label="@string/app_name">
        <intent-filter >
            <action android:name="android.intent.action.DEFAULT" />

            <category android:name="android.intent.category.LAUNCHER" />

        </intent-filter>
    </activity>



</application>

我该怎么办感谢您的帮助

很难看到没有在实际创建Dialog地方看到代码,但是我猜你是:

  1. 创建Dialog时不使用Activity作为Context Activity上下文包含主题; 如果您尝试使用该Application则不会获得正确的主题。
  2. Dialog主题设置为不继承自Theme.AppCompat (使用构造函数setStyle()ContextThemeWrapper )。

无论哪种方式, Dialog都不会获取Theme.AppCompat提供的必需属性。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM