我想将gridViewStrings
翻译成另一种语言,如Français和Deutsch:
CustomAdapter.java:
public class MainActivity extends AppCompatActivity {
Toolbar toolbar;
CollapsingToolbarLayout collapsingToolbarLayoutAndroid;
CoordinatorLayout rootLayoutAndroid;
GridView gridView;
Context context;
ArrayList arrayList;
public static String[] gridViewStrings = {
"ALPHABETS",
"NUMBERS",
"MONTH",
"DAYS",
"ANIMALS",
"CALL US",
};
答案 0 :(得分:0)
在/res/values/string-de/string.xml,/res/values/string-fr,/res/values/string/string.xml中定义gridViewStrings ... 并使用它加载。
<string-array name="gridViewString">
<item>ALPHABETS</item>
<item>NUMBERS</item>
<item>MONTH</item>
<item>ANIMALS</item>
<item>CALL US</item>
</string-array>
以这种方式加载它:
Resources res = getResources();
String[] planets = res.getStringArray(R.array.gridViewString);
此后,您将加载与设备设置匹配的翻译。
了解更多信息https://developer.android.com/guide/topics/resources/string-resource.html#Plurals