使用TabHost装载活动,当切换活动时,使活动刷新问题(执行oncreate()方法)

  

使用TabHost装载了活动,切换,活动页面的时候,

如果需要刷新活动中的内容(切换时执行活动的oncreate()方法),

方法很简单:代码如下

//公用的TabSpec实例   private  TabHost.TabSpec  buildTabSpec (String 标签,int  resLabel,, int  resIcon,   final  Intent 内容),{   return  this.mtabhost   .newTabSpec(标签)   .setIndicator (getString (resLabel),   getresource () .getDrawable (resIcon))   .setContent(内容);   }//TabHost的addTab方法   tabHost.addTab (buildTabSpec (“ACTIVE_TAB”, R.string.active,   R.drawable.icon_huodong_n,,   new 意图(,,DemoActivity.class) .addFlags (Intent.FLAG_ACTIVITY_CLEAR_TOP)));

只需addTab时对TabSpec的实例中的意图增加

.addFlags (Intent.FLAG_ACTIVITY_CLEAR_TOP)



使用TabHost装载活动,当切换活动时,使活动刷新问题(执行oncreate()方法)