安卓tabwidget意图标签刷新每一击 [英] android tabwidget intent tabs refresh every hit
本文介绍了安卓tabwidget意图标签刷新每一击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用有孩子的标签意图创建一个标签,这样,当过用户点击标签的意图得到刷新。
在选项卡每次用户点击我要刷新,并呼吁在OnCreate儿童意图的选项卡的方法。
公共类Tabs3扩展TabActivity {
@覆盖
保护无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
最终TabHost tabHost = getTabHost();
tabHost.addTab(tabHost.newTabSpec(TAB1)
.setIndicator(名单)
.setContent(新意图(这一点,List1.class)));
tabHost.addTab(tabHost.newTabSpec(TAB2)
.setIndicator(照片列表)
.setContent(新意图(这一点,List8.class)));
//这个选项卡设置的目的标志,以便它在每次重新
//标签被点击。
tabHost.addTab(tabHost.newTabSpec(TAB3)
.setIndicator(消灭)
.setContent(新意图(这一点,Controls2.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
}
}
解决方案
添加 .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
完成所需的东西。
I want to create a tab using child tab having intents, so that when ever user click on tabs intents get refresh.
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)));
}
}
解决方案
Adding .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
fulfilled the desired thing.
这篇关于安卓tabwidget意图标签刷新每一击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文