我有一个扩展 AppCompatActivity 的主要活动,当应用程序启动时,会立即执行 AsyncTask 并显示一个带有繁忙指示器的对话框窗口。在应用程序启动时运行时崩溃,我收到以下 logcat 错误。
我还参考了一些帖子,并尝试了其中一种建议的解决方案,例如添加以下行
<item name="windowActionBar">false</item>
到styles.xml,但它没有解决问题
样式.xml
<resources>
<!-- 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>
对话框布局
<?xml version="1.0" encoding="utf-8"?>
<TextView
android:id="@+id/act_main_tv_phase_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="task in progress"
android:textAppearance="?android:attr/textAppearanceLarge" />
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/act_main_tv_phase_name"
android:layout_centerHorizontal="true"
android:minWidth="56dp">
<ProgressBar
android:layout_width="32dp"
android:layout_height="32dp"
android:id="@+id/act_main_pb_busy_indicator"/>
</FrameLayout>
日志猫:
FATAL EXCEPTION: main
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: Process: com.example.com.vpager_00, PID: 20764
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.com.vpager_00/com.example.com.ecoassistant_01.ActMain}: java.lang.IllegalArgumentException: AppCompat does not support the current theme features: { windowActionBar: false, windowActionBarOverlay: false, android:windowIsFloating: false, windowActionModeOverlay: false, windowNoTitle: false }
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2689)
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2754)
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: at android.app.ActivityThread.access$900(ActivityThread.java:177)
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448)
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: at android.os.Looper.loop(Looper.java:145)
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5938)
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:372)
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: Caused by: java.lang.IllegalArgumentException: AppCompat does not support the current theme features: { windowActionBar: false, windowActionBarOverlay: false, android:windowIsFloating: false, windowActionModeOverlay: false, windowNoTitle: false }
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:422)
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:279)
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:253)
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: at com.example.com.ecoassistant_01.ActMain.initViews(ActMain.java:456)
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: at com.example.com.ecoassistant_01.ActMain.onCreate(ActMain.java:519)
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:6288)
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2642)
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2754)
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: at android.app.ActivityThread.access$900(ActivityThread.java:177)
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448)
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: at android.os.Looper.loop(Looper.java:145)
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5938)
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:372)
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
02-15 10:05:50.429 20764-20764/com.example.com.vpager_00 E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
02-15 10:06:26.039 20764-20764/com.example.com.vpager_00 I/Process: Sending signal. PID: 20764 SIG: 9