Android图书馆项目 - 资源$ NotFoundException [英] Android Library Project - Resources$NotFoundException

查看:151
本文介绍了Android图书馆项目 - 资源$ NotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个库项目,将其用于Unity3d插件。一切都是正确的,但是当我试图显示一个自定义progressDialog,例如我这样做,获取资源$ NotFoundException

  LayoutInflater inflater =(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
查看layout = inflater.inflate(com.myapp.test.R.layout.loading,null);
layout.setMinimumWidth((int)(displayRectangle.width()* 0.9f));
layout.setMinimumHeight((int)(displayRectangle.height()* 0.9f));

progress.setView(layout);

我做错了什么?我的库项目(jar文件)似乎不包含任何布局或资源...我已经放入eclipse Is Library的首选项为true。

解决方案

您无法将资源打包到jar文件中。建议您在Android项目中创建一个图书馆项目并引用它。



有关更多信息,请查看以下链接




I'm trying to create a library project to use it for a Unity3d Plugin. All is correct but when i'm trying to show a custom progressDialog for example i'm doing this, getting Resources$NotFoundException

    LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View layout = inflater.inflate(com.myapp.test.R.layout.loading, null);
            layout.setMinimumWidth((int)(displayRectangle.width() * 0.9f));
            layout.setMinimumHeight((int)(displayRectangle.height() * 0.9f));

            progress.setView(layout);

I'm doing something wrong? My Library project ( jar file ) seems that not contains any layouts or resources... I have put in preferences of eclipse Is Library true.

解决方案

You cannot package resources into a jar file. Suggest you make a library project and refer the same in your android project.

For more information check the link below

http://developer.android.com/tools/projects/index.html

Right click on the project, goto properties, choose android, choose Is Library (tick).

To refer a library project in yout android project

Right click on your android project, goto properties, choose android, click add, browse and add the library project. Click apply and ok.

Snap shot of adding actionbaesherlock library project. Note the green tick.

Clean and build.

http://developer.android.com/tools/projects/projects-eclipse.html

这篇关于Android图书馆项目 - 资源$ NotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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