android TabHost 切换禁止重新create

enendala 2012-12-25 09:01:17
在网上找了很久,大家在使用TabHost的时候,都是不会在切换的时候去重新create,如果需要重新刷新的话,会在intent里面addFlag(clear_top),可是我并不想每次切换都会执行create,也没有addFlag(clear_top),但是还是每次都会执行ceate.
下面是我addTab的方法,大家帮忙瞧瞧。
 
private void addTab(String tag, String text, Class<?> activityClass, Drawable drawable) {
Intent intent = new Intent();
intent.setClass(this, activityClass);
TabHost.TabSpec tabSpec = mTabHost.newTabSpec(tag);
tabSpec.setIndicator(text, drawable);
tabSpec.setContent(intent);
mTabHost.addTab(tabSpec);
}
}
...全文
109 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

80,361

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧