无法解析资源的Andr​​oid日食 [英] could not resolve resource android eclipse

查看:1798
本文介绍了无法解析资源的Andr​​oid日食的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Andorid的发展新。
我已经根据 http://developer.android创建我的Andr​​oid的第一个项目。 COM /培训/基础/​​ firstapp /创建-project.html

I am new in andorid development. I have created my android first project according to http://developer.android.com/training/basics/firstapp/creating-project.html

这里是code,我有作为创建项目(无变化是由我在code完成)

And here is the code that I have as the project was created(no changes are done in code by me)

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

</RelativeLayout>

下面是图形化布局的屏幕截图
http://imageshack.us/a/img35/5284/android1s.png

Here is the screenshot of the Graphical layout http://imageshack.us/a/img35/5284/android1s.png

因此​​,它看起来罚款了,但如果我想改变文字世界,你好,比方说,你好,所以code的部分看起来像的android:文本=@字符串/你好,我得到的错误

So, it looks fine for now, but if I want to change the text Hello world to , say, hello, so the code's part looks like android:text="@string/hello", I get the error

注:此项目包含资源的错误,因此,AAPT没有成功,这可能会导致渲染失败。第一个解决资源问题。

无法解析资源@字符串/你好,并在图形布局文本变得
@字符串/你好,因为它是在此图像中

Couldn't resolve resource @string/hello, and the text in graphical layout becomes @string/hello, as it is in this image

http://imageshack.us/a/img826/7735/android2p.png

不过,我注意到一件事:
如果此错误后,我去 RES /价值/ strings.xml中并添加字符串与名称和值你好,像

But I noticed one thing: If after this error I go to res/values/strings.xml and add String with name and value hello, like

http://img842.imageshack.us/img842/8108/android3s.png

错误消失,我可以看到这个词你好中的图形布局。

The error disappears and I can see the word hello in the graphical layout.

我尝试这些至今


  1. 使用 CTRL + SHIFT + S 就像是这里描述的http:/ /stackoverflow.com/a/14462434/932473

  2. 关闭并重新打开Eclipse的。

  3. 清洗,rebulding

  4. 删除整个项目,并再次创造。

  1. Using ctrl+shift+s like it is described here http://stackoverflow.com/a/14462434/932473
  2. Closing and reopening Eclipse.
  3. cleaning, rebulding
  4. removing the entire project and creating again.

文件夹并在水库存在

这些问题没有解决我的问题。

None of these questions solved my problem

<一个href=\"http://stackoverflow.com/questions/9240995/eclipse-could-not-resolve-string-resource-error\">Eclipse无法解析字符串资源错误

不能解析的Andr​​oid资源字符串

更新时间:
如果我写这样的的android:文本=你好
我得到了日食此警告
硬codeD字符串hello,应使用@string资源

我不我要使用一些字符串,比如安卓每次得到它$ C> hello2 的strings.xml

I do not get it every time I want to use some string like android:text="@string/hello2", I have to first manually specify hello2 it in strings.xml ?

推荐答案

在RES /价值/ strings.xml中

In res/values/strings.xml

      <string name="hello">Hello</string>

然后在你的TextView参考字符串作为

Then refer the string in your textview as

      android:text="@string/hello"

我猜你没有类似上面的东西。因此,你占用资源未发现异常怎么把资源没有在strings.xml中定义

I guess you do not have something similar to above. Hence you get resource not found exception coz the resource is not defined in strings.xml

                 or

您可以按照以下做

       <string name="hello_world">hello</string> // change the string in strings.xml      
       android:text="@string/hello_world"  

有关在评论这个问题。

这篇关于无法解析资源的Andr​​oid日食的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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