string - Android:使用字符串 ID 调用字符串资源
问题描述
从这个方法开始:
weatherIconView.setIconResource(getString(R.string.wi_day_sunny));
我想使用 API 中的 iconID 接收器来调用 string.xml 文件中的特定字符串:
<string name="wi_00d"></string>
现在,我无法命名以数字开头的字符串,API 提供了所有以数字开头的 iconID。所以我尝试将“wi_”连接到 iconID 的字符串,但是当我尝试使用它调用该方法时:
iconName = "wi_" + iconId;
weatherIconView.setIconResource(getString(R.string.iconName));
它只是不起作用(很确定我以错误的方式接近这个。有正确的方法吗?或者我应该尝试其他方法吗?
解决方案
推荐阅读
- php - 一个接收正数的PHP数组函数,返回最大值,如果数组为空则返回0
- python - 在脚本的其余部分使用选定的文件
- github - 已解决:从 Heroku 仪表板连接到 Github 时出错
- html - 如何通过纯 CSS 为电子邮件客户端设置以省略号结尾的线夹?
- web - 交互式元素(锚标签)在 ipad 中滑动时没有获得焦点并带有画外音
- c# - 如何以编程方式单击 TextBlock?
- salesforce - 如果 salesforce 中有多个经理,则限制经理与其下属之间的记录级别访问权限
- java - 当我们将spring boot类注解为@EnabletransactionManagement时,是否默认创建了transactionManager Bean?
- javascript - 如何在 React 中控制多个复选框?
- sql - 我有 Store_Id,日期级别的数据,并且必须使用 SQL 标记是否每周访问该商店