应用程序扩展ActionBarActivity时崩溃 [英] App crashes when extending ActionBarActivity
问题描述
我有一个错误捕捉时,我对 ActionBarActivity
。如果我延长活动
有没有错误。
的事情是在我的其他活动,它完美的作品。起初,我还以为这是是因为我的previous活动把群众演员的意图。但是,即使没有它的应用程序崩溃。
下面是我的code:
进口android.support.v7.app.ActionBarActivity;
进口android.os.Bundle;
公共类FullscreenActivity扩展ActionBarActivity {
@覆盖
保护无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.activity_fullscreen);
}
}
编辑:和日志的结果是:
09-21 18:21:39.413:E / AndroidRuntime(26944):致命异常:主要
09-21 18:21:39.413:E / AndroidRuntime(26944):java.lang.RuntimeException的:无法启动的活动ComponentInfo {com.example.testlfm / com.example.testlfm.FullscreenActivity}:java.lang.IllegalStateException:你需要使用Theme.AppCompat主题(或后代)与本次活动。
09-21 18:21:39.413:E / AndroidRuntime(26944):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2308)
09-21 18:21:39.413:E / AndroidRuntime(26944):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2358)
09-21 18:21:39.413:E / AndroidRuntime(26944):在android.app.ActivityThread.access $ 600(ActivityThread.java:153)
09-21 18:21:39.413:E / AndroidRuntime(26944):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1247)
09-21 18:21:39.413:E / AndroidRuntime(26944):在android.os.Handler.dispatchMessage(Handler.java:99)
09-21 18:21:39.413:E / AndroidRuntime(26944):在android.os.Looper.loop(Looper.java:137)
09-21 18:21:39.413:E / AndroidRuntime(26944):在android.app.ActivityThread.main(ActivityThread.java:5227)
09-21 18:21:39.413:E / AndroidRuntime(26944):在java.lang.reflect.Method.invokeNative(本机方法)
09-21 18:21:39.413:E / AndroidRuntime(26944):在java.lang.reflect.Method.invoke(Method.java:511)
09-21 18:21:39.413:E / AndroidRuntime(26944):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:795)
09-21 18:21:39.413:E / AndroidRuntime(26944):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
09-21 18:21:39.413:E / AndroidRuntime(26944):在dalvik.system.NativeStart.main(本机方法)
09-21 18:21:39.413:E / AndroidRuntime(26944):java.lang.IllegalStateException:产生的原因,您需要使用Theme.AppCompat主题(或后代)与本次活动。
09-21 18:21:39.413:E / AndroidRuntime(26944):在android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:102)
09-21 18:21:39.413:E / AndroidRuntime(26944):在android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:58)
09-21 18:21:39.413:E / AndroidRuntime(26944):在android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)
09-21 18:21:39.413:E / AndroidRuntime(26944):在com.example.testlfm.FullscreenActivity.onCreate(FullscreenActivity.java:36)
09-21 18:21:39.413:E / AndroidRuntime(26944):在android.app.Activity.performCreate(Activity.java:5104)
09-21 18:21:39.413:E / AndroidRuntime(26944):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
09-21 18:21:39.413:E / AndroidRuntime(26944):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2262)
09-21 18:21:39.413:E / AndroidRuntime(26944):11 ...更多
根据您所发表的错误:你需要使用一个Theme.AppCompat主题(或后代)与本次活动你应该使用appcompat库作为图书馆计划,在这种情况下,你会看到在该项目下RES /值可用主题
I have an error catch when I extend ActionBarActivity
. If I extend Activity
there is no errors.
The thing is in my other activities it works perfectly. At first, I thought it's was because my previous activity put extras in the intent. But even without it the app crash.
Here is my code :
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
public class FullscreenActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fullscreen);
}
}
EDIT : and the result of logs :
09-21 18:21:39.413: E/AndroidRuntime(26944): FATAL EXCEPTION: main
09-21 18:21:39.413: E/AndroidRuntime(26944): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testlfm/com.example.testlfm.FullscreenActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
09-21 18:21:39.413: E/AndroidRuntime(26944): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2308)
09-21 18:21:39.413: E/AndroidRuntime(26944): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2358)
09-21 18:21:39.413: E/AndroidRuntime(26944): at android.app.ActivityThread.access$600(ActivityThread.java:153)
09-21 18:21:39.413: E/AndroidRuntime(26944): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247)
09-21 18:21:39.413: E/AndroidRuntime(26944): at android.os.Handler.dispatchMessage(Handler.java:99)
09-21 18:21:39.413: E/AndroidRuntime(26944): at android.os.Looper.loop(Looper.java:137)
09-21 18:21:39.413: E/AndroidRuntime(26944): at android.app.ActivityThread.main(ActivityThread.java:5227)
09-21 18:21:39.413: E/AndroidRuntime(26944): at java.lang.reflect.Method.invokeNative(Native Method)
09-21 18:21:39.413: E/AndroidRuntime(26944): at java.lang.reflect.Method.invoke(Method.java:511)
09-21 18:21:39.413: E/AndroidRuntime(26944): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
09-21 18:21:39.413: E/AndroidRuntime(26944): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
09-21 18:21:39.413: E/AndroidRuntime(26944): at dalvik.system.NativeStart.main(Native Method)
09-21 18:21:39.413: E/AndroidRuntime(26944): Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
09-21 18:21:39.413: E/AndroidRuntime(26944): at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:102)
09-21 18:21:39.413: E/AndroidRuntime(26944): at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:58)
09-21 18:21:39.413: E/AndroidRuntime(26944): at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)
09-21 18:21:39.413: E/AndroidRuntime(26944): at com.example.testlfm.FullscreenActivity.onCreate(FullscreenActivity.java:36)
09-21 18:21:39.413: E/AndroidRuntime(26944): at android.app.Activity.performCreate(Activity.java:5104)
09-21 18:21:39.413: E/AndroidRuntime(26944): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
09-21 18:21:39.413: E/AndroidRuntime(26944): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2262)
09-21 18:21:39.413: E/AndroidRuntime(26944): ... 11 more
As per the error you have posted: "You need to use a Theme.AppCompat theme (or descendant) with this activity." You should be using the appcompat library as a Library Project, in which case you'll see the available themes under res/values in that project
这篇关于应用程序扩展ActionBarActivity时崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!