我有像这样的字符串资源
<string name="my_string">Чек от %1$d до 2000 рублей</string>
我在 TextView
中使用这个字符串并且需要在 View 初始化上设置默认值。所以,我知道我可以用 context.getString(R.string.my_string, 100)
做什么。但是,我想在TextView
中做到这一点xml 定义。
有没有办法在 TextView
中使用字符串格式xml?类似的东西
android:text="@string/my_string{100}"
最佳答案
您不能将格式化参数放入 XML 中,只能放入 Java 代码中。
关于android - Android 中通过 xml 进行字符串格式化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31161316/