Android的资源不加载 [英] Android resources not loading

查看:105
本文介绍了Android的资源不加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我处理问题的资源了一会儿,我无法弄清楚。问题是,我的资源(形状,梯度,布局)不应该像他们在应用程序加载。例如:

Hey there, i'm dealing with resources issue for a while and i cannot figure it out. The thing is that my resources(shapes, gradients, layouts) don't load up in application like they should. For instance:

我的layout.xml文件(主要布局为活动)

My "layout.xml" file (main layout for activity)

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/favourite_rest"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:background="@drawable/activ_favourite_bck"
    android:layout_height="wrap_content"
    android:layout_weight="1">
            ...

和布局背景:activ_favourite_bck.xml

And layout for background: "activ_favourite_bck.xml"

<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
    android:startColor="#55555555"
    android:centerColor="#77777777"
    android:centerY="0.5"
    android:endColor="#55555555"
    android:angle="270" />
  </shape>

在这种情况下,当我运行我的应用程序,brackground是纯黑色的一样,没有背景设置,但是当我从activ_favourite_bck.xml背景定义的文件重命名为halabala.xml(与改变主要布局Android的参考:背景=@绘制/ halabala),背景是存在的,一切工作正常。但我不希望类似名称妨碍我的资源,以便它的作品。我想他们的名字由他们purpuse所以后来当我有更多的人有没有乱。我知道有命名约定的资源文件名可以用_只包含小字符而这正是我休耕。

In this case when i run my application, brackground is pure black like no background is set, but when i rename the file with background definition from activ_favourite_bck.xml to "halabala.xml" ( with changing reference in main layout android:background="@drawable/halabala") the background is there and everything is working fine. But i don't want to name my resources like retard so it works. I want to name them by they purpuse so later when i have more of them there is no mess. I know there is naming convention that resource filename can contain only small characters with "_" and that's what i'm fallowing.

注:文件是由IDE的认可,有建筑,我可以从code参考文件中没有错误

Note: the file is recognized by IDE, there are no errors during building and i can reference file from code.

我与Android 1.6的API回环,但我试图更改为2.0,2.2 ..没有成功。我也尝试过各种手机类型和仿真器,我试图改变从IDE到日食IDEA和没有什么帮助。我试图重建项目,刷新可以刷新:)我试图擦去没有影响设备的应用一切。是任何人面临同样的问题,喜欢我吗?

I'm woring with android 1.6 api, but i tried changing to 2.0, 2.2.. with no success. I also tried various phone types and emulator and i tried changing IDE from eclipse to IDEA and nothing helps. I tried rebuilding project, refreshing everything that can be refreshed:) i tried to wipe the application from devices with no effect. Is anybody facing similar issue like me?

顺便说一句。同样的事情是怎么回事,当我在绘制文件夹放一些图片(PNG),我从XML引用它。有些照片(仅重命名到别的sometning后,他们确认)确认(在运行的应用程序中所示),有些不是。

Btw. the same thing is going on when i put some picture(png) in drawable folder and i'm referencing it from xml. Some pictures are recognized (and shown in running application) and some not( they are recognized only after renaming to sometning else).

推荐答案

几个小时后,我的工作了这一点。我probaly小心删除文件夹中的绘制-MDPI 。创建并复制影像出现后,一切工作就好了。

After couple of hours i worked this out. I probaly accidentally removed folder drawable-mdpi. After creating it and copying images there everything works just fine.

这篇关于Android的资源不加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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