i have been working passing result created onpostexecute
of asynctask
in fragment
. know how in activity
, ((myactivity)context).somemethod();
how can in fragment
?
i ((myfragment)contextofasynctask).methodinfragment()
gives me error "cannot cast context myfragment".
here code in asynctask
class asyncmethod extends asynctask{
arraylist<myobject> myvar= new arraylist<myobject>(); string result; listview lv; context contextofasynctask; public asyncmethod(context xc, listview xl){ contextofasynctask= xc; lv = xl; } @override protected void onpreexecute() { } @override protected void doinbackground(void...param) { httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost(http://www.myurl.com/something.php); httpresponse httpresponse = httpclient.execute(httppost); httpentity httpentity = httpresponse.getentity(); result = entityutils.tostring(httpentity); return null; //everything working fine here, , can value } @override protected void onpostexecute(void res) { //it not work here ((myfragment)contextofasynctask).methodinfragment(result); }
Comments
Post a Comment