java - Protocol not found -
my code:
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 object of student maginfo latestnews=getitem(postion); log.d("latestnews", latestnews.getpdf()); //populate custom list view 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(); } } }
error:
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:
try change
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 object of student maginfo latestnews=getitem(postion); log.d("latestnews", latestnews.getpdf()); //populate custom list view class of student tv1.settext(latestnews.gettitle()); //tv2.settext(latestnews.getimg()); string image=latestnews.getimg(); imgurl=imgstore+image; log.d("imageurl", ""+imgurl); return item; }
to this.
public view getview(int postion,view contentview,viewgroup parent) { view item=inflater.inflate(r.layout.mag_listview,parent,false); //creating object of student maginfo latestnews=getitem(postion); log.d("latestnews", latestnews.getpdf()); string image=latestnews.getimg(); imgurl=imgstore+image; new displayimagefromurl((imageview) item.findviewbyid(r.id.imageview1)) .execute(imgurl); textview tv1=(textview) item.findviewbyid(r.id.textview1); tv1.settext(latestnews.gettitle()); return item; }
Comments
Post a Comment