private String Urlstring = "http://www.weather.com.cn/data/cityinfo/101120501.html";
TextView right_location;
TextView right_kind;
TextView right_temhigh;
TextView right_temlow;
private void initweather() {
right_location = (TextView) menuView.findViewById(R.id.right_location);
right_kind = (TextView) menuView.findViewById(R.id.right_kind);
right_temhigh = (TextView) menuView.findViewById(R.id.right_temhigh);
right_temlow = (TextView) menuView.findViewById(R.id.right_temlow);
requestQueue = Volley.newRequestQueue(this);
StringRequest request = new StringRequest(Urlstring,
new Listener<String>() {
@Override
public void onResponse(String arg0) {
Log.i("arg0", arg0);
JSONObject dataJson;
try {
dataJson = new JSONObject(arg0);
JSONObject response = dataJson.getJSONObject("weatherinfo");
String city = response.getString("city");
String temp2 = response.getString("temp2");
String temp1 = response.getString("temp1");
String weather = response.getString("weather");
// SharedPreferences.Editor editor = sp.edit();
// editor.putString("city", city);
// editor.putString("temp", temp2 + "~" + temp1);
// editor.putString("state", weather);
// editor.commit();
right_location.setText(city);
right_temhigh.setText(temp1);
right_temlow.setText(temp2);
right_kind.setText(weather);
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new ErrorListener() {
@Override
public void onErrorResponse(VolleyError arg0) {
// TODO Auto-generated method stub
}
});
requestQueue.add(request);
}