安卓新手 在实验中遇到shutting down VM的错误不知道如何修改,求解答 THX!!

在logcat中现实的问题是这样的:
10-11 08:15:51.676 16168-16168/com.example.administrator.activitylifecycletest E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.administrator.activitylifecycletest, PID: 16168
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.administrator.activitylifecycletest/com.example.administrator.activitylifecycletest.DialogActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.AppCompatDelegateImplV9.createSubDecor(AppCompatDelegateImplV9.java:356)
at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:325)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:286)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.example.administrator.activitylifecycletest.DialogActivity.onCreate(DialogActivity.java:11)
at android.app.Activity.performCreate(Activity.java:6662)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707) 
at android.app.ActivityThread.-wrap12(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6077) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
求大神指导要怎样修改 跪谢orz

4个回答

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.administrator.activitylifecycletest/com.example.administrator.activitylifecycletest.DialogActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
这才是你的错误原因,你的DialogActivity的主题要使用Theme.App.compat的才行

shenshucong520
glustful 回复weixin_40125606: androidmanifest.xml文件里注册DialogActivity时给他设置theme为Theme.App.Compat啊
接近 3 年之前 回复
weixin_40125606
weixin_40125606 oooo这样啊 那要怎样修改呢
接近 3 年之前 回复

你在style里面设置Theme.AppCompat就OK了

weixin_40125606
weixin_40125606 好的解决了!多谢
接近 3 年之前 回复

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.administrator.activitylifecycletest/com.example.administrator.activitylifecycletest.DialogActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
这才是你的错误原因,你的DialogActivity的主题要使用Theme.App.compat的才行

activity所对应的主题不对

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问