Note that there are some explanatory texts on larger screens.

plurals
  1. POactionbarsherlock using tabnavigation tan navigation
    primarykey
    data
    text
    <p>I have a late requirement change that requires tab navigation. I have already using ActionBarSherlock in my application. Previously my UI consisted of Activities. However from what i read the TabBar requires Fragment Activities? How is there any way i can keep my existing code and implement the TabBar or would this require a complete re write of my application ? All of my activities extends SherlockActivity ?</p> <p>Kind Regards,</p> <pre><code>import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentTransaction; import android.support.v4.view.ViewPager; import com.actionbarsherlock.app.ActionBar; import com.actionbarsherlock.app.ActionBar.Tab; import com.actionbarsherlock.app.SherlockFragmentActivity; public class NewMainActivity extends SherlockFragmentActivity implements ActionBar.TabListener, ViewPager.OnPageChangeListener { private ViewPager mViewPager; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.textlayout); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(new MainPagerAdapter(getSupportFragmentManager())); mViewPager.setOnPageChangeListener(this); //mViewPager.setPageMarginDrawable(R.drawable.border); mViewPager.setPageMargin(16); final ActionBar actionBar = getSupportActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.addTab(actionBar.newTab().setText("First Tab").setTabListener(this)); actionBar.addTab(actionBar.newTab().setText("Second Tab").setTabListener(this)); actionBar.addTab(actionBar.newTab().setText("Third Tab").setTabListener(this)); } @Override public void onPageScrollStateChanged(int arg0) { // TODO Auto-generated method stub } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { // TODO Auto-generated method stub } @Override public void onPageSelected(int arg0) { // TODO Auto-generated method stub } @Override public void onTabSelected(Tab tab, FragmentTransaction ft) { mViewPager.setCurrentItem(tab.getPosition()); } @Override public void onTabUnselected(Tab tab, FragmentTransaction ft) { // TODO Auto-generated method stub } @Override public void onTabReselected(Tab tab, FragmentTransaction ft) { // TODO Auto-generated method stub } private class MainPagerAdapter extends FragmentPagerAdapter { public MainPagerAdapter(FragmentManager fm) { super(fm); } @Override public Fragment getItem(int position) { switch (position) { case 0: // return (mFragmentA = new FragmentA()); case 1: // return (mFragmentB = new FragmentB()); case 2: // return (mFragmentC = new FragmentC()); } return null; } @Override public int getCount() { return 3; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload