0
A
回答
0
请注明你的问题问得更具描述性的方式任何方式我在此基础上了解请看看在你指的是什么样的ID代码
intent = new Intent(this, HomeGroup.class);
View tab1 = _inflater.inflate(R.layout.custom_tab_1,null);
homeTab.setTag("Tab1");
spec = tabHost.newTabSpec("Tab1").setIndicator(tab1).setContent(intent);
tabHost.addTab(spec);
View tab2 = _inflater.inflate(R.layout.custom_tab_2,null);
homeTab.setTag("Tab2");
spec = tabHost.newTabSpec("Tab2").setIndicator(tab2).setContent(intent);
tabHost.addTab(spec);
View tab3 = _inflater.inflate(R.layout.custom_tab_3,null);
homeTab.setTag("Tab3");
spec = tabHost.newTabSpec("Tab3").setIndicator(tab3).setContent(intent);
tabHost.addTab(spec);
tabHost.setOnTabChangedListener(this);
//click on seleccted tab
int numberOfTabs = tabHost.getTabWidget().getChildCount();
for(int t=0; t<numberOfTabs; t++){
tabHost.getTabWidget().getChildAt(t).setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction()==MotionEvent.ACTION_UP){
String currentSelectedTag = MainTab.this.getTabHost().getCurrentTabTag();
String currentTag = (String)v.getTag();
Log.d(this.getClass().getSimpleName(), "currentSelectedTag: " + currentSelectedTag + " currentTag: " + currentTag);
if(currentSelectedTag.equalsIgnoreCase(currentTag)){
MainTab.this.getTabHost().setCurrentTabByTag(currentTag);
String newSelectedTabTag = MainTab.this.getTabHost().getCurrentTabTag();
if(newSelectedTabTag.toLowerCase().indexOf("tab1")!=-1){
//do smthg
}else if(newSelectedTabTag.toLowerCase().indexOf("tab1")!=-1){
//do smthg
}else if(newSelectedTabTag.toLowerCase().indexOf("tab3")!=-1){
//do smthg
}
return true;
}
}
return false;
}
});
}
+0
谢谢你的回复,但这对我不起作用,因为当通过参数开始活动时,我需要通过ID切换不同的选项卡。但是你的回答需要在活动启动后监控行动。 – Eagle
相关问题
- 1. 如何通过它的id在Primefaces tabview中设置活动选项卡?
- 2. 通过单击选项卡外部的链接设置活动选项卡?
- 3. Laravel设置选项卡活动在foreach
- 4. 设置一个选项卡从活动
- 5. Winapi设置活动选项卡控件
- 6. UIB选项卡 - 设置第二个选项卡是活动的
- 7. 为AJAX选项卡控件设置活动选项卡
- 8. angularui选项卡设置活动选项卡及其css
- 9. 如何为选项卡式活动设置不同的动作
- 10. 如何通过其ID设置select元素的选定选项?
- 11. 如何使用滑动选项卡和ViewPager设置片段ID?
- 12. jQuery如何设置第一个选项卡活动?
- 13. 如何设置片段到Android选项卡式活动
- 14. 如何在验证时使用angularJs设置活动选项卡
- 15. 如何在Primefaces tabView中设置活动选项卡?
- 16. 如何设置使用脆皮形式的活动选项卡?
- 17. 如何设置选项卡容器中的活动选项卡而不使用选项卡的索引?
- 18. 如何设置选项卡
- 19. 如何通过jQuery设置活动选项卡选择标签内容超出ul元素的位置?
- 20. 如何设置选项卡2在启动选项卡页面设置为默认选项卡
- 21. 激活选项卡通过导航
- 22. 通过可见性动态设置TabContainer Active选项卡
- 23. 带有超过3个选项卡的选项卡式活动
- 24. 如何获取wxnotebook中活动选项卡的选项卡号?
- 25. 如何禁用Android中选项卡内活动的选项卡
- 26. 如何将图像放置在android的选项卡活动选项卡中?
- 27. 如何从另一个活动中识别Tabhost选项卡ID
- 28. 在ASP.NET MVC中设置一个启动选项卡活动
- 29. JQUERY:在动画菜单选项卡上设置活动状态
- 30. 如何切换活动选项卡?
?视图ID?这实际上并不合理,因为“TabHost”不直接与视图交互。相反,它使用'TabSpec'。您可以通过TabSpec的索引或标签来选择标签。通常你不会自己使用后者,所以基于索引的依然存在。 –