WeatherNew:
package com.weatherdemo.New; public class WeatherNew { // private String resultcode; // private String reason; // private String error_code; // sk/*当前实况天气*/ private String temp;/* 当前温度 */ private String wind_direction; /* 当前风向 */ private String wind_strength;/* 当前风力 */ private String humidity;/* 当前湿度 */ private String time;/* 更新时间 */ private String city; private String date_y; private String week; private String temperature;/* 今日温度 */ private String weather;/* 今日天气 */ // weather_id/*天气唯一标识*/ private String fa;/* 天气标识00:晴 */ private String fb;/* 天气标识53:霾 如果fa不等于fb,说明是组合天气 */ private String wind;/* 风 */ private String dressing_index;/* 穿衣指数 */ private String dressing_advice;/* 穿衣建议 */ private String uv_index;/* 紫外线强度 */ private String comfort_index;/* 舒适度指数 */ private String wash_index;/* 洗车指数 */ private String travel_index;/* 旅游指数 */ private String exercise_index;/* 晨练指数 */ private String drying_index;/* 干燥指数 */ public WeatherNew(String temp, String wind_direction, String wind_strength, String humidity, String time, String city, String date_y, String week, String temperature, String weather, String fa, String fb, String wind, String dressing_index, String dressing_advice, String uv_index, String comfort_index, String wash_index, String travel_index, String exercise_index, String drying_index) { super(); this.temp = temp; this.wind_direction = wind_direction; this.wind_strength = wind_strength; this.humidity = humidity; this.time = time; this.city = city; this.date_y = date_y; this.week = week; this.temperature = temperature; this.weather = weather; this.fa = fa; this.fb = fb; this.wind = wind; this.dressing_index = dressing_index; this.dressing_advice = dressing_advice; this.uv_index = uv_index; this.comfort_index = comfort_index; this.wash_index = wash_index; this.travel_index = travel_index; this.exercise_index = exercise_index; this.drying_index = drying_index; } public String getTemp() { return temp; } public void setTemp(String temp) { this.temp = temp; } public String getWind_direction() { return wind_direction; } public void setWind_direction(String wind_direction) { this.wind_direction = wind_direction; } public String getWind_strength() { return wind_strength; } public void setWind_strength(String wind_strength) { this.wind_strength = wind_strength; } public String getHumidity() { return humidity; } public void setHumidity(String humidity) { this.humidity = humidity; } public String getTime() { return time; } public void setTime(String time) { this.time = time; } public String getCity() { return city; } public void setCity(String city) { this.city = city; } public String getDate_y() { return date_y; } public void setDate_y(String date_y) { this.date_y = date_y; } public String getWeek() { return week; } public void setWeek(String week) { this.week = week; } public String getTemperature() { return temperature; } public void setTemperature(String temperature) { this.temperature = temperature; } public String getWeather() { return weather; } public void setWeather(String weather) { this.weather = weather; } public String getFa() { return fa; } public void setFa(String fa) { this.fa = fa; } public String getFb() { return fb; } public void setFb(String fb) { this.fb = fb; } public String getWind() { return wind; } public void setWind(String wind) { this.wind = wind; } public String getDressing_index() { return dressing_index; } public void setDressing_index(String dressing_index) { this.dressing_index = dressing_index; } public String getDressing_advice() { return dressing_advice; } public void setDressing_advice(String dressing_advice) { this.dressing_advice = dressing_advice; } public String getUv_index() { return uv_index; } public void setUv_index(String uv_index) { this.uv_index = uv_index; } public String getComfort_index() { return comfort_index; } public void setComfort_index(String comfort_index) { this.comfort_index = comfort_index; } public String getWash_index() { return wash_index; } public void setWash_index(String wash_index) { this.wash_index = wash_index; } public String getTravel_index() { return travel_index; } public void setTravel_index(String travel_index) { this.travel_index = travel_index; } public String getExercise_index() { return exercise_index; } public void setExercise_index(String exercise_index) { this.exercise_index = exercise_index; } public String getDrying_index() { return drying_index; } public void setDrying_index(String drying_index) { this.drying_index = drying_index; } @Override public String toString() { return "WeatherNew [temp=" + temp + ", wind_direction=" + wind_direction + ", wind_strength=" + wind_strength + ", humidity=" + humidity + ", time=" + time + ", city=" + city + ", date_y=" + date_y + ", week=" + week + ", temperature=" + temperature + ", weather=" + weather + ", fa=" + fa + ", fb=" + fb + ", wind=" + wind + ", dressing_index=" + dressing_index + ", dressing_advice=" + dressing_advice + ", uv_index=" + uv_index + ", comfort_index=" + comfort_index + ", wash_index=" + wash_index + ", travel_index=" + travel_index + ", exercise_index=" + exercise_index + ", drying_index=" + drying_index + "]"; } }
WeatherDemoLogic:
package com.weatherdemo; import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.http.client.ClientProtocolException; import org.json.JSONException; import com.weatherdemo.New.JsonWeather; import com.weatherdemo.until.HttpUtil; import com.weatherdemo.until.JsonActivityNew; import com.weatherdemo.New.WeatherDemo; public class WeatherDemoLogic { /** * 未来几天天气 * 获取网上内容 */ public List<WeatherDemo> WeatherDemo(String cityname) throws ClientProtocolException, IOException, JSONException { Map<String, String> map = new HashMap<String, String>(); // map.put("key", "c1bb4fcbf131db6aa9b451d52b09cbae"); // map.put("dtype", "json"); // map.put("cityname", cityname); map.put("format", "2"); map.put("cityname", cityname); map.put("key", "c1bb4fcbf131db6aa9b451d52b09cbae"); // String str = HttpUtil.getRequest("forecast3h", map); String str = HttpUtil.getRequest("index", map); //System.out.println("str---"+str); List<WeatherDemo> requst = JsonWeather.getWeather(str); //System.out.println("requst---"+requst); return requst; } /** * 未来3小时天气 * 获取网上内容 */ public List<Map<String, String>> WeatherDemo1(String cityname) throws ClientProtocolException, IOException, JSONException { Map<String, String> map = new HashMap<String, String>(); //map.put("key", "c1bb4fcbf131db6aa9b451d52b09cbae"); //map.put("dtype", "json"); //map.put("cityname", cityname); map.put("format", "2"); map.put("cityname", cityname); map.put("key", "c1bb4fcbf131db6aa9b451d52b09cbae"); //String str = HttpUtil.getRequest("forecast3h", map); String str = HttpUtil.getRequest("index", map); //System.out.println("str---"+str); List<Map<String, String>> requst = JsonActivityNew.getMenuDemoh(str); //System.out.println("requst---"+requst); return requst; } }