我正在使用 yahoo API 开发一个简单的天气应用程序。
该方法weatherInfo.getCurrentText()
生成一个带有当前天气状况的英文字符串。
对于每种天气条件,都有一个分配的代码(此处的条件列表 + 代码)
我想做的是获取代码weatherInfo.getCurrentCode()
并使用自定义字符串。这将使我能够提供正确的翻译。
我正在尝试使用字符串数组来做到这一点:
<string-array name="weather_conditions">
<item0>Sunny</item0>
<item1>Cloudy</item1>
etc...
</string-array>
那么,一旦我得到天气代码,有什么方法可以在我的字符串数组上分配项目?
mWeatherCode = 获取代码(假设为 10)
mText.setText(我的数组列表中的 item10)