Reputation: 11
I want to use multi language in my app but cant solve problem with array; I couldn't define text from XML
here. So what do you advise me to do here so that i can use multi language ? thanks a lot
public static final String[] columns = { "Bluetooth", "WiFi",
"Mobile Networks", "Auto Sync", "Gps", "Auto-rotate screen",
"Vibrate on touch", "Airplane mode", "Brightness", "Sleep",
"Volume Settings", "Phone Ringtone", "Uninstall",
"Backup & Restore", "Battery Usage", "Cache Clear", "System Clear",
"System Info" };
}
Upvotes: 0
Views: 1348
Reputation: 3031
You can define string array in strings.xml, as the documentation says like:
<resources>
...
<string-array name="numbers">
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
<item>6</item>
<item>7</item>
<item>8</item>
<item>9</item>
<item>10</item>
</string-array>
...
</resources>
Than you can get it from code like :
String [] fiilliste = getResources().getStringArray(R.array.numbers);
Don't forget to define your array in every strigns.xml in each of your values-XX folder which you want to support.
Upvotes: 2
Reputation: 969
I think the best approach is to use R.string.whateveryouwant as Integer array, something like this:
Integer[] columns = { R.string.bluetooth, R.string.wifi, .... }
And when you display the text get the value from the language xml file, given the Integer key.
Upvotes: 0