tabs - Android TabHost setCurrentTab() -


i use tabhost , have 2 tabs 2 activityes want set second tab default tab when tabhost start load first tab1 , before tab2 wrong because in these 2 activityes load data webservice ! question how set current tab second tab without load first tab!

my tabhost code:

public class tabshandler extends tabactivity    { private static tabhost tabhost; intent intent;     private void setuptabhost() {     tabhost = (tabhost) findviewbyid(android.r.id.tabhost);     tabhost.setup(this.getlocalactivitymanager());     tabhost.setcurrenttab(1);     }     @override     protected void oncreate(bundle savedinstancestate) {             super.oncreate(savedinstancestate);             if(!isonline())                 utils.dialognointernet(this);             string authtoken = getintent().getextras().getstring("token");             long role = getintent().getextras().getlong("role");             string eventidnotification =getintent().getextras().getstring("eventidnotification");             setcontentview(r.layout.event_list_tabs);                  setuptabhost();             resources res = getresources();             tabhost.gettabwidget().setclipchildren(false);               setuptab(new textview(this), res.getstring(r.string.tab1_list),new intent().setclass(this, eventlistactivity.class).putextra("authtoken", authtoken).putextra("role", role).putextra("eventidnotification", eventidnotification));             setuptab(new textview(this), res.getstring(r.string.tab2_list),new intent().setclass(this, pasteventlistactivity.class).putextra("authtoken", authtoken).putextra("role", role).putextra("ispast", "true"));             tabhost.setcurrenttab(1);        }     public void switchtab(int tab){             tabhost.setcurrenttab(tab);     }     public boolean isonline() {         connectivitymanager cm =             (connectivitymanager) getsystemservice(context.connectivity_service);         networkinfo netinfo = cm.getactivenetworkinfo();         if (netinfo != null && netinfo.isconnectedorconnecting()) {             return true;         }         return false;     }     private void setuptab(final view view, final string tag,intent intent) {             view tabview = createtabview(tabhost.getcontext(), tag);             tabspec setcontent = tabhost.newtabspec(tag);             setcontent.setindicator(tabview);             setcontent.setcontent(intent);             tabhost.addtab(setcontent);     }      private static view createtabview(final context context, final string text) {              view view = layoutinflater.from(context).inflate(r.layout.tabs_bg, null);             textview tv = (textview) view.findviewbyid(r.id.tabstext);             tv.settext(text);             return view;     } 

public class tabshandler extends tabactivity    { private static tabhost tabhost;    intent intent; private void setuptabhost() { tabhost = (tabhost) findviewbyid(android.r.id.tabhost); tabhost.setup(this.getlocalactivitymanager()); tabhost.setcurrenttab(2); } @override protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         if(!isonline())             utils.dialognointernet(this);         string authtoken = getintent().getextras().getstring("token");         long role = getintent().getextras().getlong("role");         string eventidnotification =getintent().getextras().getstring("eventidnotification");         setcontentview(r.layout.event_list_tabs);              setuptabhost();         resources res = getresources();         tabhost.gettabwidget().setclipchildren(false);           setuptab(new textview(this), res.getstring(r.string.tab1_list),new intent().setclass(this, eventlistactivity.class).putextra("authtoken", authtoken).putextra("role", role).putextra("eventidnotification", eventidnotification));         setuptab(new textview(this), res.getstring(r.string.tab2_list),new intent().setclass(this, pasteventlistactivity.class).putextra("authtoken", authtoken).putextra("role", role).putextra("ispast", "true"));         tabhost.setcurrenttab(2);    } public void switchtab(int tab){         tabhost.setcurrenttab(tab); } public boolean isonline() {     connectivitymanager cm =         (connectivitymanager) getsystemservice(context.connectivity_service);     networkinfo netinfo = cm.getactivenetworkinfo();     if (netinfo != null && netinfo.isconnectedorconnecting()) {         return true;     }     return false; } private void setuptab(final view view, final string tag,intent intent) {         view tabview = createtabview(tabhost.getcontext(), tag);         tabspec setcontent = tabhost.newtabspec(tag);         setcontent.setindicator(tabview);         setcontent.setcontent(intent);         tabhost.addtab(setcontent); }  private static view createtabview(final context context, final string text) {          view view = layoutinflater.from(context).inflate(r.layout.tabs_bg, null);         textview tv = (textview) view.findviewbyid(r.id.tabstext);         tv.settext(text);         return view; } 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -