在strings.xml中错误:无效的符号“继续” [英] Error in strings.xml: invalid symbol 'continue'

查看:116
本文介绍了在strings.xml中错误:无效的符号“继续”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的strings.xml文件,我有

In my strings.xml file I have

<string name="continue">Continue</string>

我不能建立我的项目,因为错误:无效的符号:'继续'。为什么我不能用这样的名字?

I can't build my project because of the error: "Invalid symbol: 'continue'". Why I can't use such a name?

推荐答案

这是因为继续是Java中的一个保留符号,因此你不能用它作为任何一个名字对象在XML文件或Java code。

It's because continue is a reserved symbol in Java, so you cannot use it as a name for any object in your XML files or Java code.

究其原因,这是一个问题,在您的项目中定义的XML被转换成Java code的Dalvik虚拟机可以理解。所以,你的code以上会转化成R.java如下:

The reason this is a problem is that the XML defined in your project is translated into Java code that the Dalvik VM can understand. So, your code above translates into the following in R.java:

public final class R {
    public static final class string {
        public static final int continue=0x7f040000;
    }
}

检查时,问题就更加明显了(可能的)产生的code。

The problem is more obvious when examining the (would-be) generated code.

请参阅保留Java符号的列表为他人避开。

See list of reserved Java symbols for others to avoid.

这篇关于在strings.xml中错误:无效的符号“继续”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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