采用匹配规则来填充String.xml中的资源
来源:互联网 发布:企业网站域名注册 编辑:程序博客网 时间:2024/05/22 10:54
第一种方案:1.在String.xml文件中申明 string内容如 <string name="format_error">请使用%1$s:%2$s:%3$s的格式</string>
2.引用该资源的时候为: String text=resources.getString(R.string.hello, "xxx");
3.在有通配符下,string节点中设置 formatted="false" 这些特殊的字符% <string formatted="false" name="hello">%1$ssHello%2$ssworld%3$s %Hello world!</string>
那么这些单独的字符就被视为 一些字符:如%就会写成385DB8,也有可能抛异常。
第二种方案:
1.在String.xml中申明:string节点:<string name="is_hall_common_summary">第ISSUE期 还有TIME停售</string>
2.引用资源:String text = context.getResources().getString(R.string.is_hall_common_summary);
3.采用org.apache.commons.lang3.StringUtils中的replaceEach();
text = StringUtils.replaceEach(text, new String[]{"xxx","zzz"}, new String[]{text1,text2});
2.引用该资源的时候为: String text=resources.getString(R.string.hello, "xxx");
3.在有通配符下,string节点中设置 formatted="false" 这些特殊的字符% <string formatted="false" name="hello">%1$ssHello%2$ssworld%3$s %Hello world!</string>
那么这些单独的字符就被视为 一些字符:如%就会写成385DB8,也有可能抛异常。
第二种方案:
1.在String.xml中申明:string节点:<string name="is_hall_common_summary">第ISSUE期 还有TIME停售</string>
2.引用资源:String text = context.getResources().getString(R.string.is_hall_common_summary);
3.采用org.apache.commons.lang3.StringUtils中的replaceEach();
text = StringUtils.replaceEach(text, new String[]{"xxx","zzz"}, new String[]{text1,text2});
- 采用匹配规则来填充String.xml中的资源
- web.xml中的url-pattern写法规则及匹配过程
- web.xml中的url-pattern写法规则及匹配过程
- web.xml中的url-pattern写法规则及匹配过程
- web.xml中的url-pattern写法规则及匹配过程
- web.xml中的url-pattern写法规则及匹配过程
- web.xml中的url-pattern写法规则及匹配过程
- web.xml中的url-pattern写法规则及匹配过程
- web.xml中的url-pattern写法规则及匹配过程
- 采用libxml2解析xml资源
- web.xml文件中缺省映射路径"/"问题以及客户端访问web资源的匹配规则
- web.xml路径匹配规则
- Flex 采用mx:XML来存储数据
- Android 采用PULL来解析XML
- Android 采用PULL来解析XML
- Android 采用PULL来解析XML
- Android 采用PULL来解析XML
- androidmanifest.xml中组件的相对路径填充规则
- Linux中判断文件是否存在
- 在内核linux-3.1-rc4中加入系统调用 (32位和64位)
- 底半部机制分析:软中断,tasklet,工作队列
- JAVA7的新特性之钻石操作符和加强的Switch语句
- java compiler level does not match the version of the installed java project facet
- 采用匹配规则来填充String.xml中的资源
- 浅谈HTTPS传输协议原理
- 第四周—3.程序的多文件组织
- Linux验证网络文件传输的完整性命令 --md5sum
- VideoCapture::retrieve
- 一个快25岁三战女人的幸运....祝福所有考研人(转自考研论坛)
- android 支持的系统级服务表
- WINCE驱动开发之中断的使用(经典整合)
- Python中使用hashlib库进行加密