如果使用的是Android库项目你怎么正确地引用XML资源? [英] When using an Android Library Project how do you reference xml resources properly?

查看:193
本文介绍了如果使用的是Android库项目你怎么正确地引用XML资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个的Andr​​oid库项目包含几种风格/主题定义的styles.xml文件。

I have an Android Library Project that contains several styles/themes defined in its styles.xml file.

通常情况下,当参照这种风格在其他一些XML布局或清单文件,你只写安卓主题=@风格/ TheNameOfTheStyle

Normally, when referencing this style in some other xml layout or manifest file, you would just write android:theme="@style/TheNameOfTheStyle"

在使用的库项目,如何依赖项目正确引用的风格呢?只是把它当作机器人:主题=@风格/ TheNameOfTheStyle给我一个错误说没有资源发现匹配的名称

When using a library project, how does the dependent project properly reference that style now? Just leaving it as android:theme="@style/TheNameOfTheStyle" gives me an error saying there is no resource found matching that name.

我想这同样的问题适用于其他类似的引用@string,@Color等。

I guess this same question applies for other references like @string, @color etc.

感谢

编辑:确定这样看来,你是想引用它就像正常的,但在Eclipse中的控制台给我这个错误:

Ok so it appears that you are suppose to reference it just like normal, but the console in eclipse is giving me this error:

错误:没有资源的发现,匹配   给定的名称(在主题,值为@风格/ THEMENAME)。

Error: No resource found that matches the given name (at 'theme' with value '@style/ThemeName').

(facepalm)修改

我只是需要清洁工程在Eclipse。现在,它的工作。

I just needed to "Clean Project" in Eclipse. Now it's working.

推荐答案

它的建立增加资源(或者仅仅是自动构建的)和清洁工程后,工程的重要帮助大部分的时间。重新启动Eclipse时要东西出问题是一个好主意,太。

Its important to build the project after adding resources (or just have autobuild on) and cleaning the project helps most of the times. Restarting Eclipse when "something" go wrong is a good idea, too.

另外请注意,Android的融合了的recources,所以最后一个项目就是打造赢这个名字。出于这个原因,它是一个好主意,以preFIX所有资源以某种方式。

Also note that Android merges the recources, so the last project that is build "wins" the name. For this reason it's a good idea to prefix ALL resources somehow.

这篇关于如果使用的是Android库项目你怎么正确地引用XML资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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