我正在尝试在我的应用程序中包括ActionBar V7。在AndroidManifest.xml中,我将

android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >


在values / style.xml中

    <resources>

        <!--
            Base application theme, dependent on API level. This theme is replaced
            by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
        -->
        <style name="AppBaseTheme" parent="Theme.AppCompat.Light">
            <!--
                Theme customizations available in newer API levels can go in
                res/values-vXX/styles.xml, while customizations related to
                backward-compatibility can go here.
            -->

    </style>
        <!-- Application theme. -->
        <style name="AppTheme" parent="AppBaseTheme">

            <!-- All customizations that are NOT specific to a particular API-level can go here. -->
        </style>

</resources>


在值-v11中

<?xml version="1.0"?>
-<resources>
<!-- Base application theme for API 11+. This theme completely replaces AppBaseTheme from res/values/styles.xml on API 11+ devices. -->
-<style parent="Theme.AppCompat.Light" name="AppBaseTheme">
<!-- API 11 theme customizations can go here. -->
</style></resources>


在值-v14中

<resources>

    <!--
        Base application theme for API 14+. This theme completely replaces
        AppBaseTheme from BOTH res/values/styles.xml and
        res/values-v11/styles.xml on API 14+ devices.
    -->
    <style name="AppBaseTheme" parent="Theme.AppCompat.Light">
        <!-- API 14 theme customizations can go here. -->
    </style>

</resources>


在我放的活动中

import android.support.v7.app.ActionBarActivity;
public class MainActivity extends ActionBarActivity


执行后告诉我项目中有错误。确切地说,所有的style.xml中都包含错误,错误是“错误:检索项目的父级时出错:找不到与给定名称'Theme.AppCompat.Light'相匹配的资源。
“为什么我有此错误以及如何修复它?我将库android-support-v7-appcompat.jar放在/ libs中,然后右键单击以将其添加到Build Patch。我也尝试重新启动Eclipse,但它无法正常工作相同。

最佳答案

v7 appcompat库除J​​AR文件外还包含资源。有关在库中包含资源的说明,请参见:

http://developer.android.com/tools/support-library/setup.html#add-library

使用资源添加库-使用Eclipse

10-08 18:54