本文介绍了格式字符串XXX不是有效的格式字符串,因此不应将其传递给String.format的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有android应用,资源中有此字符串:
I have android app and this string in resources:
<string name="create_group_select_people">Select up to %1$d people!</string>
这是从片段中调用的:
Integer countMax = 5; //also tried just "int" - nothing changed
getResources().getString(R.string.create_group_select_people, countMax);
但是我得到了错误:
Format string 'create_group_select_people' is not a valid format string so it should not be passed to String.format
我不明白怎么了?当我启动应用程序时-从字面上显示最多选择%1 $ d个人!"
I can't understand what is wrong? When I launch app - it shows me literally "Select up to %1$d people!"
推荐答案
我只是复制了代码,所以效果很好.所以您可能需要检查其他地方,这是我的建议.
I just copied the code and it works well.so you may need to check some other place,Here are my suggestions.
- 清洁项目
- 检查多语言文件
- 或者像其他人一样使用String.format
这篇关于格式字符串XXX不是有效的格式字符串,因此不应将其传递给String.format的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!