我想在我的应用程序中使用多语言,但无法解决数组问题;我无法在此处XML
定义文字。那么你建议我做什么,以便我可以使用多语言?非常感谢
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" };
}
答案 0 :(得分:2)
您可以在strings.xml中定义字符串数组,如documentation所示:
<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>
你可以从以下代码中获取它:
String [] fiilliste = getResources().getStringArray(R.array.numbers);
不要忘记在您要支持的每个values-XX文件夹中的每个strigns.xml中定义数组。
答案 1 :(得分:0)
我认为最好的方法是使用R.string.whateveryouwant作为整数数组,如下所示:
Integer [] columns = {R.string.bluetooth,R.string.wifi,....}
当您显示文本时,从给定的Integer键获取语言xml文件中的值。