getString(int resId, Object... formatArgs)的用法
来源:互联网 发布:我的淘宝店铺链接地址 编辑:程序博客网 时间:2024/05/22 12:54
public final String getString (int resId,Object... formatArgs)
Return a localized formatted string from the application's package's default string table, substituting the format arguments as defined inFormatter andformat(String, Object...).
官方文档地址:http://developer.android.com/reference/android/content/Context.html#getString%28int,%20java.lang.Object...%29
使用示例:
1. %s对应字符串
String tiptext =getString(R.string.format_error,"用户名","昵称","密码");
strings.xml 中 format_error 为:
<string name="format_error">请使用%1$s:%2$s:%3$s的格式</string>
返回结果: tiptext ="请使用用户名:昵称:密码的格式";
2.%d 对应整数
String tiptext =getString(R.string.photo_select_complete, 3,10));
strings.xml 中 photo_select_complete 为:
<string name="photo_select_complete">完成(%1$d/%2$d)</string>
返回结果: tiptext ="完成(3/10)";
注意:%d 对应整数 %s对应字符串
3 0
- getString(int resId, Object... formatArgs)的用法
- Context类getString(@StringRes int resId, Object... formatArgs)的使用
- String android.content.Context.getString(int resId, Object... formatArgs)
- String android.content.Context.getString(int resId, Object... formatArgs)的使用
- 我的Android进阶之旅------>Android中可替换string的使用,getString(int resId, Object... formatArgs)
- Resources类中getString (int ResID)与getText (int ResID)的区别
- Android getText(int resId)和getString(int resId)
- Android getText(int resId)和getString(int resId)
- Android getText(int resId)和getString(int resId)
- RS.GetString ()的用法
- asp的 rs.GetString 用法
- %1$s和Object...以及getString() 和 getResources().getString()用法区别
- View.setBackgroundResource(int resId)当resId代表的Drawable带有Padding时,会改变View本身的Padding值
- TextView使用getString(resId, args)对args设置字体颜色
- ResultSet 中的getString()方法的用法?
- 关于LayoutInflater.inflater(int resId,ViewGroup root,boolean attchtoroot)第三个参数的问题
- Activity-setContentView(int resId)源码分析
- getString()方法用法详解
- c++实验报告 打印图形
- jpa自动建表出错
- 泛型T约束
- 安装cnpm加快npm install安装速度
- eclipse安装cdt插件
- getString(int resId, Object... formatArgs)的用法
- 转盘
- 编写优质嵌入式C程序
- nodejs 异步io 解决for循环最佳方案
- android dpi dip px
- Unity DrawCall优化
- Linux学习笔记之软件安装管理
- [Android] Android开发优化之——从代码角度进行优化
- iOS-此证书的签发者无效