Android开发过程中主题崩溃的应用程序

时间:2014-03-27 05:24:32

标签: android android-layout

我有一个问题。当我将主题更改为Theme.Black.NoTitleBar.Fullscreen时,我不知道为什么我的应用程序无法在模拟器或我的Note 3上运行。什么时候我试图运行它。模拟器显示强制关闭按钮并显示错误消息。我被卡住了,请帮忙!谢谢

这些是我的logcat

中抛出的错误
03-27 07:01:34.127: D/AndroidRuntime(2619): Shutting down VM
03-27 07:01:34.127: W/dalvikvm(2619): threadid=1: thread exiting with uncaught exception (group=0xa4d05b20)
03-27 07:01:34.127: E/AndroidRuntime(2619): FATAL EXCEPTION: main
03-27 07:01:34.127: E/AndroidRuntime(2619): Process: com.example.crystalball, PID: 2619
03-27 07:01:34.127: E/AndroidRuntime(2619): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.crystalball/com.example.crystalball.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
03-27 07:01:34.127: E/AndroidRuntime(2619):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
03-27 07:01:34.127: E/AndroidRuntime(2619):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
03-27 07:01:34.127: E/AndroidRuntime(2619):     at android.app.ActivityThread.access$800(ActivityThread.java:135)
03-27 07:01:34.127: E/AndroidRuntime(2619):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
03-27 07:01:34.127: E/AndroidRuntime(2619):     at android.os.Handler.dispatchMessage(Handler.java:102)
03-27 07:01:34.127: E/AndroidRuntime(2619):     at android.os.Looper.loop(Looper.java:136)
03-27 07:01:34.127: E/AndroidRuntime(2619):     at android.app.ActivityThread.main(ActivityThread.java:5017)
03-27 07:01:34.127: E/AndroidRuntime(2619):     at java.lang.reflect.Method.invokeNative(Native Method)
03-27 07:01:34.127: E/AndroidRuntime(2619):     at java.lang.reflect.Method.invoke(Method.java:515)
03-27 07:01:34.127: E/AndroidRuntime(2619):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
03-27 07:01:34.127: E/AndroidRuntime(2619):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
03-27 07:01:34.127: E/AndroidRuntime(2619):     at dalvik.system.NativeStart.main(Native Method)
03-27 07:01:34.127: E/AndroidRuntime(2619): Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
03-27 07:01:34.127: E/AndroidRuntime(2619):     at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:111)
03-27 07:01:34.127: E/AndroidRuntime(2619):     at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:58)
03-27 07:01:34.127: E/AndroidRuntime(2619):     at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)
03-27 07:01:34.127: E/AndroidRuntime(2619):     at com.example.crystalball.MainActivity.onCreate(MainActivity.java:19)
03-27 07:01:34.127: E/AndroidRuntime(2619):     at android.app.Activity.performCreate(Activity.java:5231)
03-27 07:01:34.127: E/AndroidRuntime(2619):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
03-27 07:01:34.127: E/AndroidRuntime(2619):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
03-27 07:01:34.127: E/AndroidRuntime(2619):     ... 11 more

1 个答案:

答案 0 :(得分:0)

日志说:

You need to use a Theme.AppCompat theme (or descendant) with this activity.
03-27 07:01:34.127: E/AndroidRuntime(2619): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)

说明:

The reason you are having this problem is because the activity you are trying 
to apply the theme to is extending ActionBarActivity which 
requires the AppCompat theme to be applied.

Change the parent of the actual java code to be just plain Activity and 
you should be able to leave the theme on it.

here挑选。

希望有所帮助!