-1
我的代码:协议未发现
public class MagAdapter extends ArrayAdapter<maginfo> {
private LayoutInflater inflater;
public String imgstore="http://******.com/cms/document/images/books/";
public static String imgurl="";
public MagAdapter(Context context,List<maginfo> newsadapter) {
super(context,R.layout.mag_listview,newsadapter);
// TODO Auto-generated constructor stub
inflater=(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// TODO Auto-generated constructor stub
}
public View getView(int postion,View contentView,ViewGroup parent) {
View item=inflater.inflate(R.layout.mag_listview,parent,false);
new DisplayImageFromURL((ImageView) item.findViewById(R.id.imageView1)).execute(imgurl);
TextView tv1=(TextView) item.findViewById(R.id.textView1);
//TextView tv2=(TextView) item.findViewById(R.id.textView2);
//creating the object of the student
maginfo latestnews=getItem(postion);
Log.d("latestnews", latestnews.getPdf());
//populate the custom list view with the class of Student
tv1.setText(latestnews.getTitle());
//tv2.setText(latestnews.getImg());
String image=latestnews.getImg();
imgurl=imgstore+image;
Log.d("imageurl", ""+imgurl);
return item;
}
private class DisplayImageFromURL extends AsyncTask<String, Void, Bitmap> {
ImageView bmImage;
public DisplayImageFromURL(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);
//pd.dismiss();
}
}
}
错误:
04-21 15:20:58.739: E/Error(1959): Protocol not found:
04-21 15:20:58.739: W/System.err(1959): java.net.MalformedURLException: Protocol not found:
非常感谢你的工作。 – Naren
为相同的代码,我得到了一个错误:04-22 12:43:57.145:D/skia(2538):--- decoder-> decode returned false – Naren