我是Android新手,我在app上工作。下载图像并在列表项中显示.i使用了很多功能。毕加索和滑翔没有显示任何东西和第三种方法我得到这个错误
" I / System.out:(HTTPLog)-Static:isSBSettingEnabled false"
所以任何解决这个问题的建议。 这是我负责该
的代码的一部分public class loader extends ArrayAdapter {
public Context context;
private LayoutInflater inflater;
private String[] img;
public loader(Context context, String[] img) {
super(context, R.layout.item, img);
this.context = context;
this.img = img;
inflater = LayoutInflater.from(context);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// ImageView imgshow = (ImageView) findViewById(R.id.image1);
if (null == convertView) {
convertView = inflater.inflate(R.layout.item, parent, false);
}
ImageView imageView = (ImageView) convertView.findViewById(R.id.imageview);
//first method
Glide.with(context)
.load(img[position])
.into(imageView);
//second method
new DownloadImageTask((ImageView) convertView.findViewById(R.id.imageview))
.execute(img[position]);
//third method
Picasso.with(context).load(img[position]).into(imageView);
return convertView;
}
private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
ImageView bmImage;
public DownloadImageTask(ImageView bmImage) {
this.bmImage = bmImage;
}
protected Bitmap doInBackground(String... urls) {
String urldisplay = urls[0];
Bitmap mIcon11 = null;
try {
InputStream in = new java.net.URL(urldisplay).openStream();
mIcon11 = BitmapFactory.decodeStream(in);
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return mIcon11;
}
protected void onPostExecute(Bitmap result) {
bmImage.setImageBitmap(result);
}
}
}
我把它放在我的列表中
lv = (ListView) findViewById(R.id.updatelist);
String[] img = new String[1000];
loader im=new loader(mainpage.this,img);
lv.setAdapter(im);
img []是一个字符串数组,包含使用json
的图像url try {
// Load json data and display
JSONObject json = new JSONObject(Content);
//String responseString = json.getString("name");
JSONArray jre = json.getJSONArray("updates");
//HashMap<String, String> project = new HashMap<String, String>();
for (int j = 0; j < jre.length(); j++) {
JSONObject jobject = jre.getJSONObject(j);
String name11 = jobject.getString("title");
String description = jobject.getString("description");
//String statu = jobject.getString("status");
String image = jobject.getString("image");
String total = url + image;
img[j] = total;
//projectname.setText(name11);
//status.setText(description);
//descrip.setText(statu);
HashMap<String, String> contact = new HashMap<>();
// adding each child node to HashMap key => value
contact.put("title", name11);
contact.put("description", description);
contact.put(url+image,total);
//contact.put("status", statu);
contactList.add(contact);
}