整型资源不是预期 [英] Integer resource not what expected
本文介绍了整型资源不是预期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下的整数资源在我的strings.xml文件
I have the following integer resources in my strings.xml file
<item type="integer" name="pID" format="integer">374</item>
<item type="integer" name="vID" format="integer">3468</item>
我要叫他们从我的code获得374和3468。
I want to call them from my code to get 374 and 3468.
不过,我输出到LogCat中...
However, when I output to Logcat...
Log.d("MainActivity.onCreate","pID: "+R.integer.pID+" vID: "+R.integer.vID);
我看到下面的...
I see the following...
pID: 2131230720 vID: 2131230721
为什么不是3468和374 respectivley其他 R.integer.vID
和 R.integer.pID
返回整数?
推荐答案
您打印出来的资源ID。使用 Resources.getInteger(RESOURCEID)
代替。
You are printing out the resource IDs. Use Resources.getInteger(resourceId)
instead.
的http://developer.android.com/guide/topics/resources/more-resources.html#Integer
这篇关于整型资源不是预期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文