"未找到资源"除了在尝试加载资源在NotepadV1样品exercice [英] "Resource not found" exception while trying to load resource in NotepadV1 sample exercice

查看:103
本文介绍了"未找到资源"除了在尝试加载资源在NotepadV1样品exercice的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的Andr​​oid(而不是Java的),我按照样品exercice NotepadV1但我得到一个奇怪的错误,而在执行上的虚拟设备(的Hello World工作得很好,就在这张VD):

I am new to Android (but not to Java), I follow sample exercice NotepadV1 but I get a strange error while executing on virtual device (Hello World worked fine on this same vd):

运行程序时,我收到了资源未找到的异常。所使用的ID是正确的(Eclipse中拿出来给我当自动完成的建议,并且它很好地R.java定义)。 如果我直接使用的字符串,而不是资源ID,所有的东西都是好的。

I get a "Resource not found" exception when running the program. The used ID is correct (Eclipse show it to me as an autocompletion proposal, and it's well defined in R.java). If I use directly the string instead of the resource ID, all things are good.

下面是我的string.xml:

Here is my string.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string
        name="app_name">Notepad v1</string>
    <string
        name="no_notes">No Notes Yet</string>
    <string
        name="menu_insert">Add Item</string>
</resources>

和这里就是抛出异常的函数:

And here is the function where the exception is thrown:

@Override
public boolean onCreateOptionsMenu( Menu menu )
{
    boolean result = super.onCreateOptionsMenu( menu );
    // menu.add( 0, INSERT_ID, 0, R.string.menu_insert ); // exception !
    menu.add( 0, INSERT_ID, 0, "Add Item" ); // ok like this
    return result;
}

该注释掉行是其中一个抛出异常。正如你看到的,直接给字符串,而不是资源ID时,它传递。 我试图在同一程序中其他地方加载这个资源,除了到处扔。其他资源用在其他地方的程序,没有问题。

The commented out line is the one which throws exception. As you see, when giving directly the string instead of resource ID, it pass. I've tried to load this resource elsewhere in the same program, and the exception is thrown everywhere. Other resources are used on other places in the program, without problem.

任何人有一个想法?难道我错过了什么?

Anybody have an idea ? Did I missed something ?

非常感谢您的想法

推荐答案

我有同样的问题和清洁项目在Eclipse中解决了这个问题。

I have had the same issue and cleaning the Project in Eclipse solved it.

这篇关于&QUOT;未找到资源&QUOT;除了在尝试加载资源在NotepadV1样品exercice的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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