📜  android 字符串 java 代码示例

📅  最后修改于: 2022-03-11 14:52:14.089000             🧑  作者: Mango

代码示例1
Let's say you want to display this and also translate it:
Hello, [display name]! You have [display an other variable] new messages.

Put your string in the strings.xml file with this %n$s as fields:
Hello, %1$s! You have %2$d new messages.

Get and set in your class in this way:
Resources res = getResources(); //previously done
String text = String.format(res.getString(R.string.welcome_messages), username, mailCount);