String url="http://118.244.212.82:9092/newsClient/news_list?ver=1&subid=1&dir=1&nid=1&stamp=20140321&cnt=20";这书JSON数据 我只是让他吐了一下丝MainActivity AppCompatActivity {
String =;
ImageView ;
onCreate(Bundle savedInstanceState) {
.onCreate(savedInstanceState);
setContentView(R.layout.);
= (ImageView) findViewById(R.id.);
RequestQueue requestQueue =Volley.();
StringRequest stringRequest = StringRequest(, Response.Listener<String>() {
onResponse(String s) {
jsonParse(s);
}
}, Response.ErrorListener() {
onErrorResponse(VolleyError volleyError) {
}
});
requestQueue.add(stringRequest);
}
jsonParse(String s){
JSONObject jsonObject = ;
{
jsonObject = JSONObject(s);
} (JSONException e) {
e.printStackTrace();
}
JSONArray jsonArray = jsonObject.optJSONArray();
(i = ; i < jsonArray.length(); i++){
JSONObject jsonObject1 =jsonArray.optJSONObject(i);
String summary = jsonObject1.optString();
String icon = jsonObject1.optString();
String stamp = jsonObject1.optString();
String title = jsonObject1.optString();
nid = jsonObject1.optInt();
String link = jsonObject1.optString();
type = jsonObject1.optInt();
Toast.(getApplicationContext(),summary.toString(),Toast.).show();
photoshow(icon);
}
}
photoshow(String s){
RequestQueue requestQueue = Volley.(getApplicationContext());
ImageRequest imageRequest = ImageRequest(s, Response.Listener<Bitmap>() {
onResponse(Bitmap bitmap) {
.setImageBitmap(bitmap);
}
}, , , Bitmap.Config., Response.ErrorListener() {
onErrorResponse(VolleyError volleyError) {
}
});
requestQueue.add(imageRequest);
}
}
添加回答
举报
0/150
提交
取消