android - static variable is null after initilization -


i have action bar activity 3 tabs. have main activity, post xml webservice , xml in asynctaskj.i'm initializing static variable of main activity in asnctask. main activity activity called, action bar initialized. each action bar has listfragment, use static variable. have no issue accessing static variable 2 list activities in first listfragment m not able access initialized static variable. please help,

thanks in advance edit 1

my main activity

submit.setonclicklistener(new onclicklistener() {          @override         public void onclick(view v) {             generatexml gx=new generatexml();             string requestxml=gx.generatexml(tv1.gettext().tostring(),tv2.gettext().tostring(),tv3.gettext().tostring(),tv4.gettext().tostring());             mynewtask = new mytask(requestxml);             mynewtask.execute();             intent intent=new intent(getapplicationcontext(),tabactivity.class);             startactivity(intent);          }     }); 

in asynctask doinbackground

mainactivity.responsexml=responsexml; 

the activity tabs created

public class tabactivity extends activity { mytask mynewtask;  /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);        actionbar actionbar = getactionbar();     actionbar.setnavigationmode(actionbar.navigation_mode_tabs);      actionbar.setdisplayshowtitleenabled(true);      /** creating tab */     tab tab = actionbar.newtab()             .settext("all")             .settablistener(new customtablistener<allmsgfragment>(this, "all", allmsgfragment.class));     //.seticon(r.drawable.android);      actionbar.addtab(tab);       /** creating success tab */     tab = actionbar.newtab()             .settext("success")             .settablistener(new customtablistener<successmsgfragment>(this, "success", successmsgfragment.class));     //.seticon(r.drawable.apple);       actionbar.addtab(tab);         /** creating error tab */     tab = actionbar.newtab()             .settext("error")             .settablistener(new customtablistener<errormsgfragment>(this, "error", errormsgfragment.class));     //.seticon(r.drawable.apple);      actionbar.addtab(tab);      } 

}

my first listfragment :

public class allmsgfragment extends listfragment { public static string response; public arraylist<hashmap<string, string>> msgdetails;   @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {     response=mainactivity.responsexml;     xmltoarraylist xmlarray=new xmltoarraylist();     try {         msgdetails=xmlarray.arraylistxml(response);     } catch (unsupportedencodingexception e) {         e.printstacktrace();     }     listadapter adapter = new simpleadapter(getactivity(), msgdetails,             r.layout.msg_preview,             new string[] { "obsystem", "obname", "msgstate"}, new int[] {         r.id.bs, r.id.si, r.id.msgstatus});     setlistadapter(adapter);      return super.oncreateview(inflater, container, savedinstancestate); }    @override public void onstart() {     super.onstart();     log.e("first","1");     /** setting multiselect choice mode listview */     getlistview().setchoicemode(listview.choice_mode_multiple);      } 

}


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -