如何使Java从XML文件调用字符串(在Android Studio中)
我有这个代码,我想让它多语言应用程序。我想要的是使用Strings.xml文件中的字符串。如何将“哥伦比亚比索”更改为字符串如何使Java从XML文件调用字符串(在Android Studio中),java,android,string,Java,Android,String,我有这个代码,我想让它多语言应用程序。我想要的是使用Strings.xml文件中的字符串。如何将“哥伦比亚比索”更改为字符串 placeHolderData.add(new ExchangeListData("COP","Colombian Peso",R.drawable.colombia,time,"1")); 更多信息: 您始终可以根据用户区域设置等,将R.string.hello标识符更改为正确的语言,即R.string.es_peso。试试这个 String Stri
placeHolderData.add(new ExchangeListData("COP","Colombian Peso",R.drawable.colombia,time,"1"));
更多信息:
您始终可以根据用户区域设置等,将R.string.hello
标识符更改为正确的语言,即R.string.es_peso
。试试这个
String String=getResources().getString(R.String.hello)
或
String=getString(R.String.hello)
要从String.xml获取字符串并将其添加到您想要的位置
Placeholder data.add(新的ExchangeListData(“COP”,字符串,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"));