I have this code and I will like to make it multi language app. What I want is to use the Strings from the Strings.xml file. How can i change "Colombian Peso" to String.
placeHolderData.add(new ExchangeListData("COP","Colombian Peso",R.drawable.colombia,time,"1"));
String string = getString(R.string.hello); // change hello to the right identifier
// then use it in your call
placeHolderData.add(new ExchangeListData("COP", string, R.drawable.colombia, time, "1"));
More info: https://developer.android.com/guide/topics/resources/string-resource#java
You can always change the R.string.hello
identifier to the right language, ie R.string.es_peso
, based on the user locale, etc.
Try this
String string = getResources().getString(R.string.hello);
Or
String string = getString(R.string.hello);
to get String from String.xml & add it to your desirable place
placeHolderData.add(new ExchangeListData("COP",string,R.drawable.colombia,time,"1"));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.