如何解析JSON数据与排球
我怎样才能让这个URL的图像..使用Volley? 我已经解析了所有其他的数据..只有url图像...有些帮助? 这是我的代码如何解析JSON数据与排球
String id =imageName.getText().toString().trim();
if (id.equals("")) {
Toast.makeText(this, "Please enter an id", Toast.LENGTH_LONG).show();
return;
}
loading = ProgressDialog.show(this, "Please wait...", "Fetching...", false, false);
String url = Url + imageName.getText().toString().trim();
Log.d("DIRECT", url);
StringRequest stringRequest = new StringRequest(url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
loading.dismiss();
showJSON(response);
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// Toast.makeText(MainActivity.this,error.getMessage()的toString(),Toast.LENGTH_LONG。).show(); } });
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(stringRequest);
}
private void showJSON(String response) {
Bitmap bmp = null;
String code = "";
String vende = "";
String image="";
String fecha = "";
String det = "";
try {
JSONObject jsonObject = new JSONObject(response);
JSONArray result = jsonObject.getJSONArray("result");
JSONObject collegeData = result.getJSONObject(0);
code = collegeData.getString("codigo");
vende = collegeData.getString("articulos");
fecha = collegeData.getString("detalle");
det = collegeData.getString("precio");
//how parsing the url image
} catch (JSONException e) {
e.printStackTrace();
}
// texto.setText("Code:\t" + code + "\nVendedeor:\t" + vende + "\nfecha:\t" + fecha + "\ndetalle:\t" + det);
imageName.setText(code);
art.setText(vende);
// imageView.setImageBitmap(bmp);
deta.setText(fecha);
pre.setText(det);
Log.d( “RES”,将String.valueOf(预)+将String.valueOf(技术)+将String.valueOf(imageName));
提前致谢!
Android毕加索图书馆是一个伟大的图书馆下载和缓存图像。
https://github.com/square/picasso
只要你能在ImageView的加载图像网址为:
Picasso.with(this).load("your_image_url").into(imageView);
谢谢你们所有的人现在工作好:) – Widy
请投票并标记为答案如果这对你有用。 –
使用图书馆像毕加索和负荷的形象像这样Picasso.with(上下文).load( “图片网址”) .into(ImageView的); 使用毕加索,添加这个作为依赖编译“com.squareup.picasso:picasso:2.4.0” –
谢谢你...要尝试 – Widy