无法为新的 Android ActionBar 支持找到 Theme.AppCompat.Light [英] Can't Find Theme.AppCompat.Light for New Android ActionBar Support

查看:20
本文介绍了无法为新的 Android ActionBar 支持找到 Theme.AppCompat.Light的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实施新的 ActionBar 支持库谷歌几天前发布的.过去,我使用 Google Developer's 支持库设置页面 - 使用关于如何包含资源的指南(这与 ActionBarSherlock 的做法类似).我也将库项目作为库加载到我自己的项目中.

I am trying to implement the new ActionBar support library that was released by Google a couple days ago. In the past, I have successfully implemented ActionBarSherlock without any issues using the same method listed on Google Developer's Support Library Setup page - using the guide on how to include the resources (which is similar to how ActionBarSherlock did it). I have the library project loaded in to my own project as a library as well.

我可以判断库加载正常.当我没有在 MainActivity.java 上扩展 Activity,而是将其更改为扩展 ActionBarActivity(按照 Google 的说明)时,没有发生错误 - 并且可以正确导入.

I can tell the library is loading fine. When, instead of extending Activity on my MainActivity.java, I changed it to extend ActionBarActivity (as per Google's instructions), no errors occur - and it imports correctly.

我什至尝试绕过 style.xml 文件并将 @style/Theme.AppCompat.Light 直接添加到 AndroidManifest.xml 中,用于 android:theme="@style/ThemeAppCompat.Light" 的所有尝试都导致相同的错误.

I even tried bypassing the style.xml file and adding @style/Theme.AppCompat.Light directly in to the AndroidManifest.xml for both <application> and <activity> with android:theme="@style/ThemeAppCompat.Light" with all attempts resulting in the same error.

现在的问题是我无法让它改变主题,更不用说甚至在不抛出错误的情况下构建.下面是我收到的错误,后面是我更改为使用新主题的 style.xml 文件.

Now the issue is I cannot get it to change the theme, let alone even build without throwing an error. Below is the error I am receiving, followed by the style.xml file I changed to use the new theme.

我有使用 Android 应用程序的中等经验,并且正在使用最新版本的支持库和使用 API 18 (Android 4.3) 编译的 SDK 运行 Eclipse.

I have moderate experience working with Android apps and am running Eclipse with the latest version of the Support Libraries and SDK compiling with API 18 (Android 4.3).

构建过程中收到错误

错误:检索项目的父项时出错:找不到与给定名称@style/Theme.AppCompat.Light"匹配的资源.style.xml/ActBarTest/res/values line 3 Android AAPT 问题

error: Error retrieving parent for item: No resource found that matches the given name '@style/Theme.AppCompat.Light'. styles.xml /ActBarTest/res/values line 3 Android AAPT Problem

style.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Theme.ProsoftStudio.ACTest" parent="@style/Theme.AppCompat.Light">
    </style>
</resources>

有什么建议吗?这对 ActionBarSherlock 来说从来都不是问题.我想继续使用这个新的支持库.似乎 .jar 正在加载,但资源没有加载.

Any suggestions? This was never an issue with ActionBarSherlock. I want to work on using this new support library. It almost seems like the .jar is loading, but not the resources.

推荐答案

接下来需要做的:

  1. 文件->导入(android-sdkextrasandroidsupportv7).选择AppCompat"
  2. 项目->属性->Android. 在部分库中添加"并选择AppCompat"
  3. 仅此而已!
  1. File->Import (android-sdkextrasandroidsupportv7). Choose "AppCompat"
  2. Project-> properties->Android. In the section library "Add" and choose "AppCompat"
  3. That is all!

注意:如果您在菜单项中使用android:showAsAction",则需要像示例中那样更改前缀 android http://developer.android.com/guide/topics/ui/actionbar.html

Note: if you are using "android:showAsAction" in menu item, you need to change prefix android as in the example http://developer.android.com/guide/topics/ui/actionbar.html

这篇关于无法为新的 Android ActionBar 支持找到 Theme.AppCompat.Light的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆