[android-developers] Re: Accessing resources or call a method from another app
> But as you can see, I have to use the int for the resource and not the
> resource id. Is there a way to reference the resource id instead, or is
> this not possible? Or, would this work just fine with the resource id, but
> Eclipse simply reports it as an error.
When you put 'R.string.x' in your java code, that's mapped to an int
at build
time in a file R.java created by the SDK.
Eclipse therefore never know what R.string.y means with reference to
another
package because it doesn't have R.java available for that package.
So yes, you have to use the int. However, if you really want to use
the resource name:
int id = otherRes.getResourceByName( "y", "string", otherPackageName);
otherRes.getString( id );
By name is slower though.
Pent
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home