java - .execute cannot be resolved to a type - AsyncTask (Android) -
im writing app needs json db, receive data, im trying view icon beside information shown in listview.
the line making trouble is:
mchart.settag(url); new downloadimagestask.execute(mchart); <------
mainactivity:
public class mainactivity extends activity { listview list; textview icon; textview name; textview developer; textview size; button btngetdata; arraylist<hashmap<string, string>> mlist = new arraylist<hashmap<string, string>>(); private static string url = "http://appwhittle.com/getdata.php"; private static final string tag_item = "app_item"; private static final string tag_icon = "app_icon"; private static final string tag_name = "app_name"; private static final string tag_developer = "app_developer"; private static final string tag_size = "app_size"; jsonarray mjsonarray = null; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); mlist = new arraylist<hashmap<string, string>>(); new jsonparse().execute(); } private class jsonparse extends asynctask<string, string, jsonobject> { private progressdialog pdialog; @override protected void onpreexecute() { super.onpreexecute(); icon = (textview)findviewbyid(r.id.icon); name = (textview)findviewbyid(r.id.name); size = (textview)findviewbyid(r.id.size); developer = (textview)findviewbyid(r.id.developer); pdialog = new progressdialog(mainactivity.this); pdialog.setmessage("getting data ..."); pdialog.setindeterminate(false); pdialog.setcancelable(true); pdialog.show(); } @override protected jsonobject doinbackground(string... args) { jsonparser jparser = new jsonparser(); // getting json url jsonobject json = jparser.getjsonfromurl(url); return json; } @override protected void onpostexecute(jsonobject json) { pdialog.dismiss(); try { mjsonarray = json.getjsonarray(tag_item); for(int = 0; < mjsonarray.length(); i++){ jsonobject c = mjsonarray.getjsonobject(i); string name = c.getstring(tag_name); string size = c.getstring(tag_size); string developer = c.getstring(tag_developer); string icon = c.getstring(tag_icon); hashmap<string, string> map = new hashmap<string, string>(); map.put(tag_icon, icon); map.put(tag_name, name); map.put(tag_developer, "developer: " + developer); map.put(tag_size, size + " mb"); mlist.add(map); list=(listview)findviewbyid(r.id.list); listadapter adapter = new simpleadapter(mainactivity.this, mlist, r.layout.list_v, new string[] {tag_name, tag_developer, tag_size }, new int[] { r.id.name, r.id.developer, r.id.size}); imageview mchart = (imageview) findviewbyid(r.id.icon); string url = "http://www...anything ..."; mchart.settag(url); new downloadimagestask.execute(mchart); list.setadapter(adapter); list.setonitemclicklistener(new adapterview.onitemclicklistener() { @override public void onitemclick(adapterview<?> parent, view view, int position, long id) { toast.maketext(mainactivity.this, "you clicked @ "+ mlist.get(+position).get(tag_name), toast.length_short).show(); } }); } } catch (jsonexception e) { e.printstacktrace(); } } } }
downloadimagestask:
public class downloadimagestask extends asynctask<imageview, void, bitmap> { imageview imageview = null; @override protected bitmap doinbackground(imageview... imageviews) { this.imageview = imageviews[0]; return download_image((string)imageview.gettag()); } @override protected void onpostexecute(bitmap result) { imageview.setimagebitmap(result); } private bitmap download_image(string url) { return null; } }
any appreciated! in advance!
replace
new downloadimagestask.execute(mchart);
with
new downloadimagestask().execute(mchart);
try this. work.
Comments
Post a Comment