Wednesday, September 14, 2011

[android-developers] Re: retrieve resource string from plain class

On 9/14/2011 3:41 PM, John Goche wrote:
>
> Hello,
>
> I would like to retrieve the value of a resource string from
> a plain class that does not have a Context superclass. Is
> this possible? I see the API:
>
> http://developer.android.com/guide/topics/resources/string-resource.html
>
> which do not list getString and getText as static methods.
>
> I tried
>
> String foo = (new Context()).getString(R.string.str_foo);
>
> but it seems I cannot do this.
>
> Any ideas?
>
> John Goche
>
> --
> 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

If this class needs a context to do its job, then pass it one in its
constructor.

--
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

No comments:

Post a Comment