ActionBarSherlock给人吨"调用需要API级别11(目前最小为7)QUOT;错误给人、最小、级别、目前

2023-09-04 10:02:52 作者:和我鬼混么

我下载ActionBarSherlock 4.0.3,解压缩,并创造了从文件夹中的新项目。该的src 文件夹是,根据Eclipse中,充满了错误,所以我也跟着各种指令线上,如添加 Android的支持 - v4.jar ,目标API设置为15和编译器符合性水平1.6。不过,该项目有194错误,所有这一切都是调用需要API级别11(目前最小为7)。所以,当我看到的错误之一,我看到这样的:

I downloaded ActionBarSherlock 4.0.3, unzipped it and created a new project from the library folder. The src folder was, according to Eclipse, full of errors, so I followed various instructions online, like adding android-support-v4.jar, setting target API to 15 and compiler compliance level to 1.6. Still, the project has 194 errors, all of which are "Call requires API level 11 (current min is 7)". So when I look at one of the errors, I see this:

@Override
public void invalidateOptionsMenu() {
    getSherlock().dispatchInvalidateOptionsMenu();
}

public void supportInvalidateOptionsMenu() {
    invalidateOptionsMenu();
    //the previous line has this error in Eclipse:
    //Call requires API level 11 (current min is 7): android.app.Activity#invalidateOptionsMenu
}

这看起来很奇怪对我来说,因为 invalidateOptionsMenu()与previous功能覆盖,但是Eclipse还是抱怨,需要一个新的API级的功能。当我看到其他的错误,我觉得这是很多其他错误太多的情况。

This looks strange to me, because invalidateOptionsMenu() is overridden with the previous function, but Eclipse still complains about the function requiring a newer API level. When I look at the other errors, I find that this is the case with many other errors too.

我有使用Python比Java更经验,所以我不明白是什么原因导致这种情况发生什么。帮助将AP preciated,而如果你的帮助,你能不能也解释了是什么原因导致这一点,你做了什么来解决呢?我不想问的人,每次我有一个问题,我要学的太多。

I have much more experience with Python than Java, so I don't understand anything of what causes this to happen. Help would be appreciated, and if you do help, could you also explain what causes this and what you did to solve it? I wouldn't want to ask someone every time I have a problem, I want to learn too.

推荐答案

由于您使用最小的API 7级,和invalidateOptionsMenu()并不存在,直到API级别11,你不能忽略它没有错误,因为如果设备运行API 7级,该功能是不可用在基类和一个不存在的功能不能被覆盖。

Since you're using min API level 7, and invalidateOptionsMenu() did not exist until API level 11, you can't override it without errors since if the device runs API level 7, the function isn't even available in the base class and a non existing function cannot be overridden.