Android渲染问题无法解析资源@ string/app_name [英] Android Rendering Problems Couldn't resolve resource @string/app_name

查看:851
本文介绍了Android渲染问题无法解析资源@ string/app_name的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是android编程的新手,我不明白自己在做什么错. 我尝试在xml文件中创建一个像这样的按钮:

I'm new to android programming and I don't understand what I'm doing wrong. I try to make a button like this in the xml file:

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/btnText"
    android:id="@+id/button"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true" />

这很好,没有android:text ="@ string/btnText"部分...

This works fine, without the android:text="@string/btnText" part...

我的strings.xml文件如下:

My strings.xml file looks like this:

<string name="btnText">GO!</string>

我收到此错误消息: 呈现问题无法解析资源@ string/app_name(未显示2个类似错误)

I get this error message: Rendering Problems Couldn't resolve resource @string/app_name (2 similar errors not shown)

问题是按钮文本显示@ string/btnText而不是GO!

The problem is that the button text says @string/btnText instead of GO!

推荐答案

[请注意,此答案于2016年针对Android Studio 2.0编写!从那时起,Android Studio发生了重大变化.这个答案在当时帮助了很多人,但可能不再有意义.]

布局预览有可能在处理所有文件之前开始绘制. Android Studio和Eclipse都经常遭受工具同步问题的困扰.

[Note that this answer was written in 2016 for Android Studio 2.0! Android Studio has changed significantly since then. This answer helped a lot of people at the time, but may no longer be relevant.]

It's possible that the layout preview started drawing before all the files were processed. Android Studio and Eclipse both frequently suffer from tool synchronization problems.

在许多情况下,只需刷新布局预览即可解决此问题(当然,我假设您已执行定义了字符串app_name).箭头标记为刷新按钮(有很多按钮!).

In many cases, simply refreshing the layout preview will solve this problem (of course I'm assuming that you do have the string app_name defined). The arrow marks the refresh button (so many buttons!).

这篇关于Android渲染问题无法解析资源@ string/app_name的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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