Roj Beraña Roj Beraña - 1 year ago 373
Android Question

(Android Xamarin) Get Resource string value instead of int

Im just starting to create a simple android app with the use of Xamarin using VS2012.
I know there is a type of Resource just for strings.
In my resource folder, i have an xml file like this:

<?xml version="1.0" encoding="utf-8"?>
<string name="RecordsTable">records</string>
<string name="ProjectTable">projects</string>
<string name="ActivitiesTable">activities</string>

In my code, I want to use the values of those resources like:

string recordTable = Resource.String.RecordsTable; //error, data type incompatibility

I know that
returns an integer so I cant use the code above.
I am hoping that
variable will have a value of

Is there a way I can use the value of those resource string for my code's string variables?

Answer Source

try it as using Resources.GetString for getting string from string Resources

Context context = this;
// Get the Resources object from our context
Android.Content.Res.Resources res = context.Resources;
// Get the string resource, like above.
string recordTable = res.GetString(Resource.String.RecordsTable);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download