gpt4 book ai didi

android - getActionBar() 的 NoSuchMethodError 错误 (API-8)

转载 作者:IT王子 更新时间:2023-10-28 23:34:49 26 4
gpt4 key购买 nike

当我运行它安装的应用程序但随后崩溃时,ecplise 并没有告诉我我的代码有什么问题。我认为这是我的 list 有问题...

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.secondapp"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />

<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.secondapp" />
</activity>
</application>

</manifest>

你们有什么问题吗?

10-19 10:41:25.589: E/AndroidRuntime(10147): FATAL EXCEPTION: main
10-19 10:41:25.589: E/AndroidRuntime(10147): java.lang.NoSuchMethodError: com.example.secondapp.MainActivity.getActionBar
10-19 10:41:25.589: E/AndroidRuntime(10147): at com.example.secondapp.MainActivity.onCreate(MainActivity.java:15)
10-19 10:41:25.589: E/AndroidRuntime(10147): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-19 10:41:25.589: E/AndroidRuntime(10147): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
10-19 10:41:25.589: E/AndroidRuntime(10147): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
10-19 10:41:25.589: E/AndroidRuntime(10147): at android.app.ActivityThread.access$1500(ActivityThread.java:123)
10-19 10:41:25.589: E/AndroidRuntime(10147): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
10-19 10:41:25.589: E/AndroidRuntime(10147): at android.os.Handler.dispatchMessage(Handler.java:99)
10-19 10:41:25.589: E/AndroidRuntime(10147): at android.os.Looper.loop(Looper.java:130)
10-19 10:41:25.589: E/AndroidRuntime(10147): at android.app.ActivityThread.main(ActivityThread.java:3835)
10-19 10:41:25.589: E/AndroidRuntime(10147): at java.lang.reflect.Method.invokeNative(Native Method)
10-19 10:41:25.589: E/AndroidRuntime(10147): at java.lang.reflect.Method.invoke(Method.java:507)
10-19 10:41:25.589: E/AndroidRuntime(10147): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
10-19 10:41:25.589: E/AndroidRuntime(10147): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
10-19 10:41:25.589: E/AndroidRuntime(10147): at dalvik.system.NativeStart.main(Native Method)

这是logcat,不知道这是否有帮助

最佳答案

使用支持库 v7 提供的 getSupportActionBar,如 here 所述在 6 上。检索操作栏部分

getSupportActionBar documentation

关于android - getActionBar() 的 NoSuchMethodError 错误 (API-8),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12977819/

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