Domanda

In Xamarin, I have the following in the strings.xml file:

<?xml version="1.0" encoding="utf-8"?>
<resources>

   <string name="app_name">AutoComplete</string>
   <string name="action_settings">Settings</string>
   <string name="hello_world">Hello world!</string>
   <string name="auto_complete">AutoComplete</string>
   <string name="multi_auto_complete">Multi AutoComplete</string>
   <string-array name="list_of_countries">
      <item >USA</item>
      <item >Uk</item>
      <item >Canada</item>
      <item >Australia</item>
      <item >France</item>
      <item >Italy</item>
      <item >China</item>
      <item >Japan</item>
      <item >Spain</item>
      </string-array>

</resources>    

How can I get the above data into an array?

Here is my current code (that does not work):

String[] countries = Resources.GetStringArray (list_of_countries);

Thanks in advance

È stato utile?

Soluzione

String[] countries = Resources.GetStringArray(Resource.Array.list_of_countries);

Path to Strings.xml:

Resources/values/Strings.xml

I hope this will help!

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top