我的 ABS TabActivity中有三个标签
public class TabActivity extends SherlockFragmentActivity {
private ViewPager mViewPager;
private TabAdapter mTabsAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getOverflowMenu();
mViewPager = new ViewPager(this);
mViewPager.setId(R.id.pager);
setContentView(mViewPager);
final ActionBar bar = getSupportActionBar();
bar.setIcon(R.drawable.actionbar_icon);
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
mTabsAdapter = new TabAdapter(this, mViewPager);
mTabsAdapter.addTab(bar.newTab().setText("").setIcon(getResources().getDrawable(R.drawable.tab_icon_join)), 1Fragment.class, null);
mTabsAdapter.addTab(bar.newTab().setText("").setIcon(getResources().getDrawable(R.drawable.tab_icon_create)), 2Fragment.class, null);
mTabsAdapter.addTab(bar.newTab().setText("").setIcon(getResources().getDrawable(R.drawable.tab_icon_play)), 3Fragment.class, null);
}
在一个单独的活动中,我有一个按钮,单击按钮时我想转到第二个选项卡。这是我到目前为止所拥有的:
public void onFinishGoToCreate(View view) {
Intent myIntent = new Intent(Activity.this, TabActivity.class);
Activity.this.startActivity(myIntent);
}
但这将我带到第一个选项卡。任何想法,将不胜感激!