问题
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>
I want to call them from my code to get 374 and 3468.
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
Why are R.integer.vID
and R.integer.pID
returning ints other than 3468 and 374 respectivley?
回答1:
You are printing out the resource IDs. Use Resources.getInteger(resourceId)
instead.
http://developer.android.com/guide/topics/resources/more-resources.html#Integer
来源:https://stackoverflow.com/questions/16112180/integer-resource-not-what-expected