android tabwidget 意图标签刷新每次点击 [英] android tabwidget intent tabs refresh every hit
本文介绍了android tabwidget 意图标签刷新每次点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用具有意图的子选项卡创建一个选项卡,以便当用户单击选项卡意图时刷新.
I want to create a tab using child tab having intents, so that when ever user click on tabs intents get refresh.
每次用户单击选项卡时,我都想刷新并调用子意图选项卡的 oncreate 方法.
Every time user click on tab i want to refresh and called oncreate method of child intent tabs.
public class Tabs3 extends TabActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final TabHost tabHost = getTabHost();
tabHost.addTab(tabHost.newTabSpec("tab1")
.setIndicator("list")
.setContent(new Intent(this, List1.class)));
tabHost.addTab(tabHost.newTabSpec("tab2")
.setIndicator("photo list")
.setContent(new Intent(this, List8.class)));
// This tab sets the intent flag so that it is recreated each time
// the tab is clicked.
tabHost.addTab(tabHost.newTabSpec("tab3")
.setIndicator("destroy")
.setContent(new Intent(this, Controls2.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
}
}
推荐答案
添加 .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
完成了想要的事情.
Adding .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
fulfilled the desired thing.
这篇关于android tabwidget 意图标签刷新每次点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文