java - I want to set a thread inside getView method how should i do it? -
the code of getview method this:
public view getview(int position, view convertview, viewgroup parent) { // todo auto-generated method stub layoutinflater inf = getlayoutinflater(); view v; v = inf.inflate(r.layout.rowdetails, parent, false); textview _tvname = (textview)v.findviewbyid(r.id.tvname); imageview _ivimg = (imageview)v.findviewbyid(r.id.ivimg); car_setget c = new car_setget(); c = arrlist.get(position); _tvname.settext(c.getname()); //loader.displayimage(c.getimg(), _ivimg, op, null); imagedownloader task = new imagedownloader(); try { bitmap image = task.execute(c.getimg()).get(); _ivimg.setimagebitmap(image); } catch(exception e) { e.printstacktrace(); } return v; } } //imagedownloader.java public class imagedownloader extends asynctask<string, void, bitmap> { @override protected bitmap doinbackground(string... urls) { // todo auto-generated method stub try { url url = new url(urls[0]); httpurlconnection connection = (httpurlconnection)url.openconnection(); connection.connect(); inputstream = connection.getinputstream(); bitmap bitmap = bitmapfactory.decodestream(is); return bitmap; } catch(exception e) { e.printstacktrace(); } return null; } }
how may solve this? want create new thread inside thread want declare whole body of getview
method. possible or not? please me.
try this:
(activity)context).runonuithread(new runnable() { public void run() { // code toast.maketext(magcontext, "hi", toast.length_short).show(); } });
Comments
Post a Comment