我正在尝试将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>
在values-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但它不起作用相同。
答案 0 :(得分:1)
除了JAR文件之外,v7 appcompat库还包含资源。有关包含资源库的说明,请访问:
http://developer.android.com/tools/support-library/setup.html#add-library
使用资源添加库 - 使用Eclipse