检索父项时出错:eclipse 中的“Theme.AppCompat.Light”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26585870/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 22:07:24  来源:igfitidea点击:

Error retrieving parent for item: 'Theme.AppCompat.Light' in eclipse

androideclipseandroid-support-libraryandroid-themeandroid-actionbaractivity

提问by user3316561

I'm trying to use ActionBarActivity in my project. I've imported the android-support-v7-appcompat to the workspace as per the instruction in https://developer.android.com/tools/support-library/setup.html#

我正在尝试在我的项目中使用 ActionBarActivity。我已按照https://developer.android.com/tools/support-library/setup.html# 中的说明将 android-support-v7-appcompat 导入工作区

I could add the appcompat project as a library in my current project (eclipse).

我可以将 appcompat 项目作为库添加到我当前的项目 (eclipse) 中。

Got the Green tick mark

得到绿色勾号

And now there is no error when I use the following import statement.

现在当我使用以下导入语句时没有错误。

import android.support.v7.app.ActionBarActivity;

And no error when I extend my class from ActionBarActivity.

当我从 ActionBarActivity 扩展我的类时没有错误。

public class MyClass extends  ActionBarActivity implements ActionBarListener  {....} 

But, I get errors while using the AppCompat style.

但是,在使用 AppCompat 样式时出现错误。

In manifest,

在清单中,

<activity
        android:name=".Activity1"
        android:label="@string/app_name"
        android:screenOrientation="portrait" 
        android:theme="@style/AppTheme"
        >
        ....

    </activity>

In styles.xml,

在styles.xml中,

<style name="AppTheme" parent="AppBaseTheme">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->

</style>


<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
    <!-- API 11 theme customizations can go here. -->
</style>

I get the following error in styles.xml while using parent="Theme.AppCompat.Light" ** error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.**

使用 parent="Theme.AppCompat.Light" ** 错误:检索父项时出错:找不到与给定名称“Theme.AppCompat.Light”匹配的资源。**

Why am I not able to access the resources from the appcompat support library.

为什么我无法访问 appcompat 支持库中的资源。

P.s: I've not used android:showAsAction="never"

ps:我没用过 android:showAsAction="never"

Both my application project and appcompat are in the same folder( I copied both to the current workspace).

我的应用程序项目和 appcompat 都在同一个文件夹中(我将它们都复制到了当前工作区)。

回答by Rohit

Try Replacing your Style.xml with this

尝试用这个替换你的 Style.xml

<style name="AppBaseTheme" parent="android:Theme.Light">

Instead of

代替

<style name="AppBaseTheme" parent="Theme.AppCompat.Light">

回答by user3316561

Worked with just a small change in styles.xml

仅在styles.xml 中稍作更改

Change

改变

 <style name="AppBaseTheme" parent="android:Theme.AppCompat">
    ...
</style>

to

<style name="AppBaseTheme" parent="@style/Theme.AppCompat">
    ...
</style>