This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 「商品名(X)はY円になります」 と出力できるように設定する。X、Yが可変パラメータ --> | |
<string name="sentece">商品名(%1$s)は%2$d円になります</string> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String sentence = getString(R.string.sentence, "ボッコちゃん", 540); | |
// sentenceに構築される文字列は「商品名(ボッコちゃん)は540円になります」になる | |
// 1$, 2$の部分がgetStringに渡される引数(パラメータ)の順番、これを囲む%s, %dは出力フォーマットを表現している | |
// フォーマットに関してはFormatterで規定されている | |
// See Also. http://developer.android.com/reference/java/util/Formatter.html |
0 件のコメント:
コメントを投稿