| 241 | private Class resource; |
| 242 | |
| 243 | public <T> void setResources(Class<T> resource) { |
| 244 | this.resource = resource; |
| 245 | if (bundle == null) { |
| 246 | bundle = new VBundle(var3dListener); |
| 247 | } |
| 248 | if (resource == null) return; |
| 249 | // 将多语言本地文本赋值到R文件,如果有的话 |
| 250 | try { |
| 251 | @SuppressWarnings("rawtypes") |
| 252 | Class R_clazz = resource; |
| 253 | @SuppressWarnings("rawtypes") |
| 254 | Class innerClazz[] = R_clazz.getDeclaredClasses(); |
| 255 | for (@SuppressWarnings("rawtypes") Class cls : innerClazz) { |
| 256 | String name = cls.getSimpleName(); |
| 257 | if (name.equals("strings")) { |
| 258 | Field[] R_fields = cls.getDeclaredFields(); |
| 259 | for (Field field : R_fields) { |
| 260 | if (field.getModifiers() == 9)// public |
| 261 | // static就等于9,不服就去吃屎 |
| 262 | field.set(null, bundle.get(field.getName())); |
| 263 | } |
| 264 | break; |
| 265 | } |
| 266 | } |
| 267 | } catch (IllegalAccessException e) { |
| 268 | e.printStackTrace(); |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | public String format(String vaule, Object... args) { |
| 273 | return bundle.formatVaule(vaule, args); |