在我的一个应用程序中,我在{{tabactivity}}和{{activitygroup}}的帮助下使用标签栏在每个屏幕中显示标签栏。
我想检测已选择的标签上的第二次点击,并实现类似于iPhone UITabbar的功能。第二次点击它将进入初始活动。
public class Tabmanagement extends TabActivity{
public static Button back;
public static TextView text;
public static Button next;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.tabmanagement);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
Resources res = getResources();
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent;
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.windowstitle);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
back=(Button)findViewById(R.id.Btn_Back);
text = (TextView) findViewById(R.id.Text_Title);
next=(Button)findViewById(R.id.Btn_Search);
spec = tabHost .newTabSpec("tab1")
.setIndicator("Topics",res.getDrawable(R.drawable.topics))
.setContent(new Intent(this,FirstGroup.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
tabHost.addTab(spec);
spec = tabHost .newTabSpec("tab2")
.setIndicator("Posts",res.getDrawable(R.drawable.post))
.setContent(new Intent(this,SecondGroup.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
tabHost.addTab(spec);
intent = new Intent().setClass(this, ThirdGroup.class);
spec = tabHost .newTabSpec("tab3")
.setIndicator("Response",res.getDrawable(R.drawable.response))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, FourthGroup.class);
spec = tabHost .newTabSpec("tab4")
.setIndicator("Settings",res.getDrawable(R.drawable.settings))
.setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(0);
}
}
答案 0 :(得分:0)
我认为这就是你要找的东西。基本上从TabHost中获取TabWidget,并在视图上设置正确的侦听器。