Android yahoo weather API的字符串和整数比较
我正在使用yahoo API开发一个简单的天气应用程序 方法Android yahoo weather API的字符串和整数比较,android,string,int,arrays,yahoo-weather-api,Android,String,Int,Arrays,Yahoo Weather Api,我正在使用yahoo API开发一个简单的天气应用程序 方法weatherInfo.getCurrentText()生成一个包含英语当前天气状况的字符串 对于每个天气条件,都有一个指定的代码() 我想做的是使用weatherInfo.getCurrentCode()获取代码,并使用自定义字符串。这将允许我提供正确的翻译 我正在尝试使用字符串数组执行此操作: <string-array name="weather_conditions"> <item0>Sunny&
weatherInfo.getCurrentText()
生成一个包含英语当前天气状况的字符串
对于每个天气条件,都有一个指定的代码()
我想做的是使用weatherInfo.getCurrentCode()
获取代码,并使用自定义字符串。这将允许我提供正确的翻译
我正在尝试使用字符串数组执行此操作:
<string-array name="weather_conditions">
<item0>Sunny</item0>
<item1>Cloudy</item1>
etc...
</string-array>
晴朗的
多云
等
那么,一旦我得到了天气代码,有什么方法可以在我的字符串数组中分配该项吗
mWeatherCode=获取代码(假设为10)
mText.setText(我数组列表上的项10)String[]conditions=getResources().getStringArray(R.array.weather_conditions);
if(mWeatherCode<0 | | mWeatherCode>conditions.length){
mText.setText(R.string.err\u无效条件);
}否则{
mText.setText(条件[mWeatherCode]);
}
String[]conditions=getResources().getStringArray(R.array.weather_conditions);
if(mWeatherCode<0 | | mWeatherCode>conditions.length){
mText.setText(R.string.err\u无效条件);
}否则{
mText.setText(条件[mWeatherCode]);
}
String[]conditions=getResources().getStringArray(R.array.weather_conditions);
if(mWeatherCode<0 | | mWeatherCode>conditions.length){
mText.setText(R.string.err\u无效条件);
}否则{
mText.setText(条件[mWeatherCode]);
}
String[]conditions=getResources().getStringArray(R.array.weather_conditions);
if(mWeatherCode<0 | | mWeatherCode>conditions.length){
mText.setText(R.string.err\u无效条件);
}否则{
mText.setText(条件[mWeatherCode]);
}
我应该继续使用阵列列表中的etc,还是只使用etc。。。同时感谢您的解决方案@iGui90只需使用…
。YahooAPI从0开始计数,ADK也从0开始计数。嗯,你需要特别处理3200。我应该继续使用数组列表中的etc还是只使用etc。。。同时感谢您的解决方案@iGui90只需使用…
。YahooAPI从0开始计数,ADK也从0开始计数。嗯,你需要特别处理3200。我应该继续使用数组列表中的etc还是只使用etc。。。同时感谢您的解决方案@iGui90只需使用…
。YahooAPI从0开始计数,ADK也从0开始计数。嗯,你需要特别处理3200。我应该继续使用数组列表中的etc还是只使用etc。。。同时感谢您的解决方案@iGui90只需使用…
。YahooAPI从0开始计数,ADK也从0开始计数。好的,你需要特别处理3200。谢谢@Chilledrat的编辑,对不起我的英语不好:)谢谢@Chilledrat的编辑,对不起我的英语不好:)谢谢@Chilledrat的编辑,对不起我的英语不好:)谢谢@Chilledrat的编辑,对不起我的英语不好:)
String[] conditions = getResources().getStringArray(R.array.weather_conditions);
if(mWeatherCode < 0 || mWeatherCode > conditions.length) {
mText.setText(R.string.err_invalid_condition);
} else {
mText.setText(conditions[mWeatherCode]);
}