Android TabHost with only selected tab on stack -


i have tabhost 4 tabs. need selected tab activity available on stack. when user changes tab, how finish activity under previous tab. tried following code. here showing code first tab. similar remaining tabs:

spec = tabhost.newtabspec("tab1").setindicator("tab1",              res.getdrawable(r.drawable.ic_tab_tab1))                     .setcontent(new intent(this, tab1.class)                     .addflags(intent.flag_activity_no_history | intent.flag_activity_clear_top)); 

but above code deleting tab1 activity on stack/heap when user comes again tab not when user changes new tab.

i've had @ this, reason this? how know what's on stack? depending on ondestroy() or something?

i haven't got full answer can see tab active:

let class implement ontabchangelistener

 public class yourclass extends tabactivity  implements ontabchangelistener {  @override protected void oncreate(bundle savedinstancestate) { // load normal objects tabhost  // make tabhost listen tab changes mtabhost.setontabchangedlistener(this); }   @override public void ontabchanged(string tabid) {     int currenttabnumber = mtabhost.getcurrenttab();     for(int i=0;i<mtabhost.gettabwidget().getchildcount();i++)     {         if(i != currenttabnumber){             system.out.println("i'm not active tab");         }                }  }   } 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -