指的Andr​​oid库项目XML资源应用XML资源 [英] refer to android library project xml resource in application xml resource

查看:147
本文介绍了指的Andr​​oid库项目XML资源应用XML资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Adnroid库项目定义XML资源。

I have an Adnroid library project that defines XML resource.

让我们用一个选择绘制为例(但我有问题的字符串,款式等)。

Let's use a selector drawable as an example (but I have problems with strings, styles, etc).

LibProject / RES /绘制/ button_selector.xml ...定义了一个选择器

LibProject/res/drawable/button_selector.xml ... defines a selector

LibProject / RES /布局/ view.xml用....使用的选择,没有任何问题。

LibProject/res/layout/view.xml .... uses the selector, with no problems

 `<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/sign_up_fly_buttons"
        android:background="@drawable/button_selector"/>`

然后我想引用它的布局在我的应用程序

Then I want to refer to it in a layout in my App

AppProject / RES /布局/ view.xml用...

AppProject/res/layout/view.xml ...

`<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/sign_up_fly_buttons"
        android:background="@drawable/button_selector"/>`

但在App它不会编译或让我引用它。 我已经试过各种空间咒语,试图引用它,没有运气...

But in the App it won't compile or let me reference it. I've tried various namespace incantations to try and refer to it with no luck...

任何想法?

增加: 我已阅读,全形式这种提法是:     @ [包名:]类型/ ID 如果你离开了包名称,然后在使用该资源文件的包。

Addition: I have read that the full-form for such references is: @[packagename:]type/id and if you leave out the package name then the package where this resource file is used.

此的例子将是:     @ com.mylibrary:绘制/ button_selector

This an example would be: @com.mylibrary:drawable/button_selector

不过,这并不为我工作!一定有什么地方错了我的图书馆的设置/进口?

But it doesn't work for me! There must be something wrong with my library setup/import?

我的图书馆是一个独立的Eclipse Android项目,标记为库项目,并从我的应用程序引用为养项目和code是建立在精细的联系。

My library is in a separate Eclipse Android project, marked as a Library project, and is referenced from my app as a "Dependent Project" and code is built and links in fine.

推荐答案

OK,发现问题!

在Eclipse中,在我的项目属性 - > Java构建路径 - >项目标签我有库项目添加

In Eclipse, in my Project Properties -> Java Build Path -> "Projects" 'tab' I had the library project added.

但是,我也必须将它添加到项目属性 - > Android的 - >库面积为库项目

BUT, I also had to add it to Project Properties -> Android -> Library area as Library Project.

我为别人做了,但忘了在这里做了。

I had done this for others, but had forgotten to do it here.

感谢所有谁试图找出我的错误。

Thanks to all who tried to figure out my mistake.

现在的资源合并在正确的,我可以用短表的格式不包名称引用它们。

Now the resources are merged in correctly and I can refer to them using the "short-form" format without the package name.

这篇关于指的Andr​​oid库项目XML资源应用XML资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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