troubled passing data from asynctask to fragment -


i seek receive data asynctask inside fragment. i'm aware achieve activity having difficulties in fragment.

getresult class

public interface getresult {      void getdata(arraylist<string> result);  } 

myfrag class

public class myfrag extends fragment implements getresult{      public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {          view = inflater.inflate(r.layout.myfrag_layout, container, false);         button mybtn = (button) view.findviewbyid(r.id.button1);          mybtn.setonclicklistener(new view.onclicklistener() {              @override             public void onclick(view arg0) {                 myasync obj = new myasync();                 obj.setlistener(getactivity());              }         });      } } 

myasync class

public class myasync extends asynctask<void, void, string>{     getresult interfaceobj = null;      public void setlistener( getresult interfaceobj ) {     this.interfaceobj =  interfaceobj;     } } 

i'm having problem obj.setlistener(getactivity). method setlistener(getresult) in type myasync not applicable arguments (fragmentactivity). in advance everyone.

i didn't figured out wt problem there way it. i'll share here.

1st interface class getresult.class same

2nd changes in fragment class myfrag.class

public class myfrag extends fragment{      public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {         view = inflater.inflate(r.layout.myfrag_layout, container, false);         button mybtn = (button) view.findviewbyid(r.id.button1);          mybtn.setonclicklistener(new view.onclicklistener() {              @override             public void onclick(view arg0) {                  getloc obj = new getloc(getactivity(), new getresultinterface() {                  @override                 public void processfinish(arraylist<string> result) {                     // u can result here                  }          obj.execute(url);          });      } } 

3rd in asynctask myasync.class

public class myasync extends asynctask<void, void, string>{     context context;     getresult interfaceobj = null;      public myasync(context context, getresultinterface interfaceobj) {         this.context = context;         this.interfaceobj = interfaceobj;     }      @override     protected void onpostexecute(arraylist<string> result) {         super.onpostexecute(result);         interfaceobj.processfinish(result);     } }  

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -