gpt4 book ai didi

java - 操作栏V7 : Why it doesn't work?

转载 作者:行者123 更新时间:2023-12-01 13:59:14 25 4
gpt4 key购买 nike

我正在尝试将 ActionBar V7 包含在我的应用程序中。在 AndroidManifest.xml 中我放入

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

在值/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>

在values-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>

在我放置的 Activity 中

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 库包含除 JAR 文件之外的资源。可以在此处找到包含资源库的说明:

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

使用资源添加库 - 使用 Eclipse

关于java - 操作栏V7 : Why it doesn't work?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19432074/

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