android Resources getString with format arguments
2015-02-16 13:19
267 查看
android的string资源可以存放一个format来供动态组合argument使用:
其实调用的就是String类的format罢了.
Context里也有一个getString(int id, Object... formatArgs), 调用的其实就是Resources的.
其实调用的就是String类的format罢了.
/** * Return the string value associated with a particular resource ID, * substituting the format arguments as defined in {@link java.util.Formatter} * and {@link java.lang.String#format}. It will be stripped of any styled text * information. * {@more} * * @param id The desired resource identifier, as generated by the aapt * tool. This integer encodes the package, type, and resource * entry. The value 0 is an invalid identifier. * * @param formatArgs The format arguments that will be used for substitution. * * @throws NotFoundException Throws NotFoundException if the given ID does not exist. * * @return String The string data associated with the resource, * stripped of styled text information. */ public String getString(int id, Object... formatArgs) throws NotFoundException { String raw = getString(id); return String.format(mConfiguration.locale, raw, formatArgs); }
Context里也有一个getString(int id, Object... formatArgs), 调用的其实就是Resources的.
相关文章推荐
- cocos2dx android版本移植时的Error format not a string literal and no format arguments解决方案
- cocos2dx android版本移植时的Error format not a string literal and no format arguments解决方案
- android 下 Error format not a string literal and no format arguments 解决方案
- String android.content.Context.getString(int resId, Object... formatArgs)的使用
- cocos2dx android版本移植时的Error format not a string literal and no format arguments解决方案
- android jni 出现format not a string literal and no format arguments [-Werror=format-security]问题
- cocos2dx android版本移植时的Error format not a string literal and no format arguments解决方案
- cocos2dx android版本移植时的Error format not a string literal and no format arguments解决方案
- cocos2dx android版本移植时的Error format not a string literal and no format arguments解决方案
- Android getResources().getStringArray() variables
- Android string format with html
- Android Studio error: format not a string literal and no format arguments [-Werror=format-security]
- Cocos2dx跨平台编译Android错误:format not a string literal and no format arguments [-Werror=format-security]
- Cocos2dx跨平台编译Android错误:format not a string literal and no format arguments [-Werror=format-security]
- cocos2dx android版本移植时的Error format not a string literal and no format arguments解决方案
- cocos2dx android版本移植时的Error format not a string literal and no format arguments解决方案
- String android.content.Context.getString(int resId, Object... formatArgs)
- How To get the Real length of a string with chinese words
- android conversion to dalvik format failed with error 1
- get Android information with adb, the build version