android - Reload current Activity clicking on active Tab -
i have tab layout , activities displayed in framelayout. how can reload current activity tab "home" clicking again on "home"-tab ?
tabtestactivity-class
public class tabtestactivity extends tabactivity implements onclicklistener{ tabhost tabhost; /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); //menÜ//////////////////////////////////////////// /** tabhost have tabs */ tabhost = (tabhost)findviewbyid(android.r.id.tabhost); /** tid1 firsttabspec id. used access outside. */ tabspec firsttabspec = tabhost.newtabspec("tid1"); tabspec secondtabspec = tabhost.newtabspec("tid2"); tabspec thirdtabspec = tabhost.newtabspec("tid3"); tabspec fourthtabspec = tabhost.newtabspec("tid4"); /** tabspec setindicator() used set name tab. */ /** tabspec setcontent() used set content particular tab. */ firsttabspec.setindicator(new myview(this, r.drawable.tabhome, "home")).setcontent(new intent(this,firstgroup.class)); secondtabspec.setindicator(new myview(this, r.drawable.tabmsg, "msgs")).setcontent(new intent(this,firstgroup.class)); thirdtabspec.setindicator(new myview(this, r.drawable.tabprofil, "profil")).setcontent(new intent(this,firstgroup.class)); fourthtabspec.setindicator(new myview(this, r.drawable.tabmehr, "mehr...")).setcontent(new intent(this,firstgroup.class)); /** add tabspec tabhost display. */ tabhost.addtab(firsttabspec); tabhost.addtab(secondtabspec); tabhost.addtab(thirdtabspec); tabhost.addtab(fourthtabspec); tabhost.setcurrenttab(0); } //layout of tabs private class myview extends linearlayout { public myview(context c, int drawable, string label) { super(c); linearlayout la = new linearlayout(c); //la.setbackgroundcolor(color.parsecolor("#3b5091")); la.setorientation(linearlayout.vertical); la.setminimumheight(63); la.setpadding(0,8,0,0); imageview iv = new imageview(c); textview tv = new textview(c); iv.setimageresource(drawable); setpadding(0,0,2,0); setorientation(linearlayout.vertical); tv.settext(label); tv.setgravity(0x01); /* center */ tv.settextcolor(color.white); la.addview(iv); la.addview(tv); addview(la); setbackgrounddrawable( getresources().getdrawable(r.drawable.tab_indicator)); } }
firstgroup-class
public class firstgroup extends activitygroup { // keep in static variable make accessible nesten activities, lets them manipulate view public static firstgroup group; // need keep track of history if want back-button work properly, don't use if activities requires lot of memory. private arraylist<view> history; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); this.history = new arraylist<view>(); group = this; // start root activity withing group , view view view = getlocalactivitymanager().startactivity("citiesactivity", new intent(this,citiesactivity.class) .addflags(intent.flag_activity_single_top)) .getdecorview(); // replace view of activitygroup replaceview(view); } public void replaceview(view v) { // adds old 1 history history.add(v); // changes groups view new view. setcontentview(v); } public void back() { if(history.size() > 0) { history.remove(history.size()-1); setcontentview(history.get(history.size()-1)); }else { finish(); } } @override public boolean onkeydown(int keycode, keyevent event) { if(keycode == keyevent.keycode_back) { firstgroup.group.back(); return true; } return super.onkeydown(keycode, event); } }
i'm not sure you're looking if want change values when user returns specific tab can in onresume method of activity.
Comments
Post a Comment