我正在开发使用tabbar的android app,使用TabGroupActivity导航意图,
Intent homeIntent = new Intent().setClass(this, SomeActivity.class);
homeIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startChildActivity("SomeActivity", homeIntent);
我想从我点击tabbar主页图标的地方重定向我的家庭活动。
答案 0 :(得分:0)
在TabActivity类中,在设置选项卡时将OnTouchListener设置为每个选项卡视图,
view.setOnTouchListener(this);
intent = new Intent().setClass(this, HomeActivity.class);
spec = tabHost.newTabSpec("home").setIndicator(view).setContent(intent);
tabHost.addTab(spec);
TabActivity类调用onTouch方法
@Override
public boolean onTouch(View view, MotionEvent event) {
// use getTabHost().getCurrentTabView to decide if the current tab is
// touched again
if (event.getAction() == MotionEvent.ACTION_DOWN
&& view.equals(getTabHost().getCurrentTabView())) {
// use getTabHost().getCurrentView() to get a handle to the view
// which is displayed in the tab - and to get this views context
if(getTabHost().getCurrentTabTag().equals("home")) {
// do what ever you want when tab home icon
}
}
return false;
}