java - Android GridView Adapter with AsyncTask -
i parse xml web , want set info gridview in other activity, can help me?
my first activity:
class="lang-java prettyprint-override">public class homescreenactivity extends activity { @override public void onclick(view v) { switch (v.getid()) { case r.id.imagebutton: intent intent = new intent(this, topartistsscreen.class); intent.putextra("username", username); new downloadxmltask(this, homescreenactivity.this) .execute("url"); startactivity(intent); }
my asynctask
class="lang-java prettyprint-override">public class downloadxmltask extends asynctask<string, void, list<artist>> { @override protected void onpostexecute(list<artist> result) { progressdialog.dismiss(); gridview.setadapter(new topartistsimageadapter(context, result)); }
topartistsimageadapter
class="lang-java prettyprint-override">@override public view getview(int position, view convertview, viewgroup parent) { view view = convertview; if(convertview==null) { view = inflater.inflate(r.layout.items, null); } textview textview = (textview) view.findviewbyid(r.id.grid_item_name); imageview imageview = (imageview) view.findviewbyid(r.id.grid_item_image); textview.settext(artistslist.get(position).getname()); imageloader.displayimage(artistslist.get(position).getimage(), imageview); homecoming view; }
ps shoud start activity after downloading information
i shoud start activity after downloading info => create changes below:
1) execute asynctask on button click
new downloadxmltask(this, homescreenactivity.this).execute("url");
2) start activity within onpostexecute() method of asynctask:
intent intent = new intent(homescreenactivity.this, topartistsscreen.class); intent.putextra("username", username); startactivity(intent);
java android gridview android-asynctask android-lazyadapter
No comments:
Post a Comment