android - public void implementation does not work in fragment -
i running asynctask in main activity , result of string vector. want use vector change list view in fragment. use interface (asyncresponce) vector public void (processfinish) , implemented asyncresponce in fragment , use clear , fill array adapter public void not work use logging statement understand if running don't see on device monitor.
i not know problem. important parts of main activity , asynctask:
asyncresponse myasync = new asyncresponse() { public void processfinish(string output[]) { } }; mainactivity.fetchweathertask weathertask = new mainactivity.fetchweathertask(myasync); //mainactivity.fetchweathertask weathertask = new mainactivity.fetchweathertask(); weathertask.execute("232931","82da4ddd2e8380be6dea06b177926b2d"); on post execute pass string vector on processfinish:
log.v(log_tag, "on post execute:+: "+ resultstrs[1]); delegate.processfinish(resultstrs); and fragment:
public class mainactivityfragment extends fragment implements mainactivity.asyncresponse { public string[] weatherdata = new string[5]; public arrayadapter<string> mforecastadapter; public final string log_tag_fragmet =mainactivityfragment.class.getsimplename(); @override public void processfinish(string output[]) { if (output!= null){ log.v(log_tag_fragmet, "this fragment="+ output[1]); mforecastadapter.clear(); } }
you should pass mainactivityfragment instance argument call new mainactivity.fetchweathertask(myasync);
the instance of asyncresponse passing has empty implementation processfinish(object[]), you're not calling mainactivityfragment
something maybe:
public class mainactivityfragment extends fragment implements mainactivity.asyncresponse { public string[] weatherdata = new string[5]; public arrayadapter<string> mforecastadapter; public final string log_tag_fragmet =mainactivityfragment.class.getsimplename(); @override public void processfinish(string output[]) { if (output!= null){ log.v(log_tag_fragmet, "this fragment="+ output[1]); mforecastadapter.clear(); } } public void somemethod() { mainactivity.fetchweathertask weathertask = new mainactivity.fetchweathertask(this); weathertask.execute("232931","82da4ddd2e8380be6dea06b177926b2d"); }
Comments
Post a Comment