【问题标题】:Android Locale app - R's full package nameAndroid Locale 应用程序 - R 的完整包名
【发布时间】:2011-04-26 02:33:33
【问题描述】:

这是设置中“区域设置”部分的来源
https://android.googlesource.com/platform/packages/apps/Settings/+/gingerbread-release/src/com/android/settings/LocalePicker.java

有谁知道R 类的完整包名是什么?奇怪的是它不在导入列表中,也不在 com/android/settings 包中。

我想要R.array.special_locale_codes 来满足我自己的需要。

【问题讨论】:

  • 同样,R 到底代表什么?我认为资源,但我永远无法确定。
  • 是的,“R”是最短的标识符(一个字母),它代表对资源文件层次结构中名称的访问。

标签: android resources


【解决方案1】:

如果没有res/values/nameofxmlcontainingarray.xml,则获取R.array.special_locale_codes 是无关紧要的

must be xml file 里面有res/values/nameofxmlcontainingarray.xml

 <?xml version="1.0" encoding="utf-8"?>  
<resources>  
<array name="special_locale_codes">  
<item>first</item>  
<item>second</item>  
<item>third</item>  
<item>fourth</item>  
<item>fifth</item>  
 </array>
</resources> 

R.array.special_locale_codes 是在构建时生成的文件。 Manually editing R.java is totally un-recommended.

R.java 包含resources which are defined inside your project which can be wired up with java code at built time。获取resources from project可以是done using R.id.componentname

FIX:If your project do contains proper resources at defined structure then you may give a try to clean your project using rightclick project-&gt;clean project

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-17
    • 1970-01-01
    • 2012-11-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多