When Tabhost is implemented with Activitygroup, the activity in TAB1 is reloaded when switching from TAB1 to TAB2 and back
public class Mainuiactivity extends activitygroup{private Context context=this; private tabhost mtabhost; private String Tab1= "Home"; Private String tab2= "collection"; Private String tab3= "3"; Private String tab4= "4"; Private String tab5= "more"; Define an array to hold the button picture private int mimageviewarray[] = {R.drawable.tab_home_btn,r.drawable.tab_message_btn,r.drawable.tab_ SELFINFO_BTN, R.drawable.tab_square_btn,r.drawable.tab_more_btn};//tab tab text Private String mtextviewarray[] = {TAB1 , TAB2, TAB3, TAB4, TAB5}; @Overrideprotected void OnCreate (Bundle savedinstancestate) {//TODO auto-generated method stubs Uper.oncreate (savedinstancestate); Setcontentview (R.layout.tab_main); mtabhost= (tabhost) findViewById ( R.ID.TABHOST1); Mtabhost.setup (); Mtabhost.setup (This.getlocalactivitymanager ()); Intent i1=new Intent (This, Mainactivity.class); Intent i_collect=new Intent (this,collectactivity.class);//intent i1=new Intent (This, Mainactivity.class);//intent i1=new Intent (this,mainactivity.class);//intent i1=new Intent (this,mainactiviTy.class) Mtabhost.addtab (Mtabhost.newtabspec (TAB1) setindicator (Gettabitemview (0)). SetContent (R.id.zhuye). SetContent (I1));///Note that this is Newtabspec (TAB2), each tab tab is written differently to save the original state Mtabhost.addtab (MTABHOST.NEWTABSPEC). Setindicator (Gettabitemview (1)). SetContent (R.id.zhuye2). SetContent (I_collect)); Mtabhost.addtab ( Mtabhost.newtabspec (TAB1). Setindicator (Gettabitemview (2)). SetContent (R.id.zhuye3). SetContent (I1)); Mtabhost.addtab (Mtabhost.newtabspec (TAB1). Setindicator (Gettabitemview (3)). SetContent (R.id.zhuye4). SetContent ( I1)); Mtabhost.addtab (Mtabhost.newtabspec (TAB1) Setindicator (Gettabitemview (4)). SetContent (R.id.zhuye5). SetContent (I1));} /** * give tab button settings icon and text */private view Gettabitemview (int index) {View view = Layoutinflater.from (context). Inflate ( R.layout.tab_item, NULL); ImageView ImageView = (ImageView) View.findviewbyid (R.id.tab_icon); Imageview.setimageresource (Mimageviewarray[index]); TextView TextView = (TextView) View.findviewbyid (r.id.tab_name); Textview.settext (Mtextviewarray[index]); return View;} public static Intent Createintent (context context) {Intent i = new Intent (context, mainactivity.class); I.addflags (Intent.flag_activity_clear_top); return i; }}The workaround is already written in the code above, which is to set a different tag for each tab tab