gpt4 book ai didi

android - 扩展 ActionBarActivity 时应用程序崩溃

转载 作者:太空宇宙 更新时间:2023-11-03 11:39:57 25 4
gpt4 key购买 nike

我在扩展 ActionBarActivity 时遇到错误捕获。如果我扩展 Activity 则没有错误。

事情是在我的其他 Activity 中它完美地工作。起初,我认为这是因为我之前的 Activity 在 Intent 中加入了额外的东西。但即使没有它,应用程序也会崩溃。

这是我的代码:

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);
}
}

编辑: 和日志结果:

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

最佳答案

根据您发布的错误:“您需要在此 Activity 中使用 Theme.AppCompat 主题(或后代)。”您应该将 appcompat 库用作库项目,在这种情况下,您将在该项目的 res/values 下看到可用的主题

关于android - 扩展 ActionBarActivity 时应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18933817/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com