how return list generated in asynctask activity?
my loadstringsasync class:
public class loadstringsasync extends asynctask<void, void, list<string> > { list<string> str; @override protected void onpreexecute() { super.onpreexecute(); ... } @override protected list<string> doinbackground(void... arg0) { ... content internet , fill list ... } @override protected void onpostexecute(list<string> str) { super.onpostexecute(events); ... } }
and need list in activity work it. (no not show in listview :p)
any suggestions how this? :-)
thanks far!
your activity:
public class youractivity extends activity { private list<string> list = new arraylist<string>(); public void oncreate(bundle state) { //... } public void setlist(list<string> list) { this.list = list; } private void fireyourasynctask() { new loadstringsasync(this).execute(); } }
asynctask:
public class loadstringsasync extends asynctask<void, void, list<string>> { list<string> str; private youracitivity activity; public loadstringsasync(youracitivity activity) { this.activity = activity; } @override protected list<string> doinbackground(void... arg0) { } @override protected void onpostexecute(list<string> str) { super.onpostexecute(events); activity.setlist(str); } }
Comments
Post a Comment