android - R.java 中的引用不是最终版本

标签 android eclipse eclipse-adt

生成样式属性的引用时,R.java 文件的生成似乎出现问题。

人们期望该字段的声明是final,但事实并非如此。怎么会这样?

res/values/attrs.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <declare-styleable name="MyTextView">
        <attr name="typeface" format="string"/>
    </declare-styleable>
</resources>

gen/com.example/R.java

    /**
      <p>This symbol is the offset where the {@link com.example.R.attr#typeface}
      attribute's value can be found in the {@link #MyTextView} array.
      <p>Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
      <p>This may also be a reference to a resource (in the form "<code>@[<i>package</i>: <i>type</i>:<i>name</i></code>") or theme attribute (in the form "<code>?[<i>package</i>: [<i>type</i>:]<i>name</i></code>") containing a value of this type. 
       @attr name com.example:typeface
    */
    public static int MyTextView_typeface = 0;

最佳答案

自几年前以来,R.java 中的引用资料都不是最终的。

这样做的原因是,如果您的主项目依赖于多个库项目,则生成的 id 可能会发生冲突。

以下是对此的更多解释:http://tools.android.com/tips/non-constant-fields

关于android - R.java 中的引用不是最终版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26634871/

相关文章:

android - eclipse 3.6.2。拒绝调试使用 Eclipse 3.6.1 构建的应用程序

android - 在 Android 的菜单图标上写文字?

android - Google 通知中的语音转文本

java - 测量来自 Android 相机的光强度

java - CheckboxCellEditor 显示文本而不是复选框

android - 提示 : Apache Cordova and Android: Unable to instantiate activity ComponentInfo

android - kurento android中的群组视频通话

Android 26 (O) 通知不显示操作图标

eclipse - 在 Spring webapp 中处理 MaxUploadSizeExceededException

android - 在 Eclipse 中将自定义参数传递给 aapt