这里是我的代码来加载图像从服务器...有什么不对? 应用程序无法加载任何东西,并显示了强制停止error.I的代码中删除的部分,我敢肯定,这就是工作...为什么我的代码无法加载任何图像?
public class MenuAdapter extends BaseAdapter{
private LayoutInflater myInflater;
private List<String> labelIDs = new ArrayList<String>();
private List<String> imageIDs = new ArrayList<String>();
public void setData(List<String> values, List<String> images){
this.labelIDs = values;
this.imageIDs = images;
}
public View getView(int position, View convertView, ViewGroup parent){
ViewHolder holder;
try {
URL url = new URL("url"+imageIDs.get(position));
Bitmap bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());
holder.ivIcon.setImageBitmap(bmp);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
holder.tvLabel.setText(labelIDs.get(position));
return convertView;
}
static class ViewHolder {
ImageView ivIcon;
TextView tvLabel;
}
}
你是什么意思?那是对的。你收到的错误是什么? – TejjD