I couldn\'t find any info about this but, how can i programmatically switch tabs in ActionBarSherlock?
Normally when i want to switch views i\'d use something like:<
In my app I have one tab fragment that has an album of pictures. When the user clicks on one of the pictures it causes that picture to be displayed in a ViewPager on the other tab fragment and automatically switches to that tab with setCurrentTabByTag().
public class EditAlbumTabs extends SherlockFragmentActivity {
TabHost mTabHost;
TabsAdapter mTabsAdapter;
public void onPagerPositionSet(int pagerPosition, String[] imageUrls) {
FragmentFlash fragmentFlash = (FragmentFlash)mTabsAdapter.getFragment("flash");
if (fragmentFlash != null) {
fragmentFlash.pagerPositionSet(pagerPosition, imageUrls);
**mTabHost.setCurrentTabByTag("flash");**
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_tabs_pager);
mTabHost = (TabHost)findViewById(android.R.id.tabhost);
mTabHost.setup();
mViewPager = (ViewPager)findViewById(R.id.pager);
mTabsAdapter = new TabsAdapter(this, mTabHost, mViewPager);
mTabsAdapter.addTab(mTabHost.newTabSpec("album").setIndicator("Album"),
FragmentAlbumFlashum.class, null);
mTabsAdapter.addTab(mTabHost.newTabSpec("flash").setIndicator("Flash"),
FragmentFlash.class, null);
}
Try calling actionBar.setSelectedNavigationItem(x):
int position = 1;
getSupportActionBar().setSelectedNavigationItem(position);