java - getResources() from within an enumeration -- Android Studio -
I just started But from within the counting type, I can not call Is this because the calculation does not extend an activity or something? How can I get the string anyway from the resources? Thank you! PS is not the foundation of counting within a class. If it is possible, then I want to put it as a separate file. Then To overcome this, I personally extended the application class and made available public static references, so that you can always use resources and this kind of complete application, no matter if you Activity or in any POJO Example: With it, you can always call: Android development Now, I have a
enumeration Want to make Within that calculation, I want to assign a name to each enum-object. I want to get that name from my project resources (
res / values / strings.xml )
getResources () .getString (R.string.string_name) .
getResources () .getString () only
getActivity () There is a short story for. GetResources () GetString () .
getResources () is still dependent on a reference (activity, piece, reference, etc.).
Public class IApp applications expanded {public static reference reference; @ Override Public Empty on Create () {Super. Connet (); Context = getApplicationContext (); }}
MyApp.context.getResources (). GetString (xxxx);
Comments
Post a Comment