Example usage for android.app ActionBar newTab

List of usage examples for android.app ActionBar newTab

Introduction

In this page you can find the example usage for android.app ActionBar newTab.

Prototype

@Deprecated
public abstract Tab newTab();

Source Link

Document

Create and return a new Tab .

Usage

From source file:edu.pdx.cecs.orcycle.TabsConfig.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    try {/* w  w  w. j  a v a  2 s.  c om*/
        myApp = MyApplication.getInstance();
        myApp.setRunning(true);
        myApp.clearReminderNotifications();

        setContentView(R.layout.tabs_config);

        Log.v(MODULE_TAG, "Cycle: TabsConfig onCreate");

        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

        // Toast.makeText(this, "Tab Created", Toast.LENGTH_LONG).show();

        fragment1 = new FragmentMainInput();
        fragment2 = new FragmentSavedTripsSection();
        fragment3 = new FragmentSavedNotesSection();
        //fragment4 = new FragmentUserInfo();
        fragment4 = new FragmentSettings();

        // Set up the action bar.
        final ActionBar actionBar = getActionBar();
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        actionBar.setBackgroundDrawable(getResources().getDrawable(R.color.psu_green));

        // Create the adapter that will return a fragment for each of the four
        // primary sections of the app.
        mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

        // Set up the ViewPager with the sections adapter.
        mViewPager = (ViewPager) findViewById(R.id.pager);
        mViewPager.setAdapter(mSectionsPagerAdapter);

        // When swiping between different sections, select the corresponding
        // tab. We can also use ActionBar.Tab#select() to do this if we have
        // a reference to the Tab.
        mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
            @Override
            public void onPageSelected(int position) {
                actionBar.setSelectedNavigationItem(position);
            }
        });

        // For each of the sections in the app, add a tab to the action bar.
        for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
            // Create a tab with text corresponding to the page title defined by
            // the adapter. Also specify this Activity object, which implements
            // the TabListener interface, as the callback (listener) for when
            // this tab is selected.

            actionBar.addTab(
                    actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
        }

        mViewPager.setOffscreenPageLimit(4);

        Intent intent;
        Bundle bundle;
        if (null != (intent = getIntent())) {
            if (null != (bundle = intent.getExtras())) {
                fragmentToShow = bundle.getInt(TabsConfig.EXTRA_SHOW_FRAGMENT, FRAG_INDEX_MAIN_INPUT);
            }
        }
    } catch (Exception ex) {
        Log.e(MODULE_TAG, ex.getMessage());
    }
}

From source file:com.vurf.vurfx.view.Place_template.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_place_template);

    // Create the adapter that will return a fragment for each of the three primary sections
    // of the app.
    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    final String TitleNames[] = new String[] { "About", "Main", "Photos" };

    // Specify that the Home/Up button should not be enabled, since there is no hierarchical
    // parent.//from  w  w w . ja va  2  s .co  m
    actionBar.setHomeButtonEnabled(false);

    // Specify that we will be displaying tabs in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Set up the ViewPager, attaching the adapter and setting up a listener for when the
    // user swipes between sections.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAppSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            // When swiping between different app sections, select the corresponding tab.
            // We can also use ActionBar.Tab#select() to do this if we have a reference to the
            // Tab.
            actionBar.setSelectedNavigationItem(position);
        }
    });
    // TODO swipy tabs 
    //PagerTitleStrip  mPagerTitleStrip = (PagerTitleStrip) findViewById(R.id.pager_title_strip);

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by the adapter.
        // Also specify this Activity object, which implements the TabListener interface, as the
        // listener for when this tab is selected.
        actionBar.addTab(actionBar.newTab().setText(TitleNames[i]).setTabListener(this));
    }
    actionBar.hide();
    //mViewPager.setCurrentItem(tab.getPosition())
    mViewPager.setCurrentItem(1);
}

From source file:it.durip_app.GraphActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_graph);
    data = new DataSource();
    // Get the message from the intent
    Intent intent = getIntent();// w  ww. j av  a 2 s  . c o m
    String paramUrl = intent.getStringExtra(MainActivity.PARAM_URL);
    int paramT = intent.getIntExtra(MainActivity.PARAM_T, 200);
    int paramI = intent.getIntExtra(MainActivity.PARAM_I, 5);
    int paramPort = intent.getIntExtra(MainActivity.PARAM_PORT, 4000);
    int paramVerbose = intent.getIntExtra(MainActivity.PARAM_VERBOSE, 1);
    data.setUrl(paramUrl);
    data.setT(paramT);
    data.setI(paramI);
    data.setPort(paramPort);
    data.setVerbose(paramVerbose);

    // kick off the data generating thread:
    mySource = new Thread(data);
    mySource.start();

    // Create the adapter that will return a fragment for each of the three primary sections
    // of the app.
    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();

    // Specify that the Home/Up button should not be enabled, since there is no hierarchical
    // parent.
    actionBar.setHomeButtonEnabled(false);

    // Specify that we will be displaying tabs in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Set up the ViewPager, attaching the adapter and setting up a listener for when the
    // user swipes between sections.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAppSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            // When swiping between different app sections, select the corresponding tab.
            // We can also use ActionBar.Tab#select() to do this if we have a reference to the
            // Tab.
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by the adapter.
        // Also specify this Activity object, which implements the TabListener interface, as the
        // listener for when this tab is selected.
        actionBar.addTab(
                actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
    // Show the Up button in the action bar.

}

From source file:app.hacked.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    //getActionBar().setIcon(R.drawable.ic_ab_logo);

    actionBar.setSubtitle("This app is UNOFFICIAL");

    queue = Volley.newRequestQueue(this);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the app.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override/*  w  w  w .  ja v  a  2 s .c  o m*/
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by
        // the adapter. Also specify this Activity object, which implements
        // the TabListener interface, as the callback (listener) for when
        // this tab is selected.
        actionBar
                .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }

    //GCM stuff
    GCMRegistrar.checkDevice(this);
    GCMRegistrar.checkManifest(this);
    regId = GCMRegistrar.getRegistrationId(this);

    if (regId.equals("")) {
        Log.v("GCM", "Registering");
        GCMRegistrar.register(this, API.SENDER_ID);
    } else {
        Log.v("GCM", "Already registered");
    }

    //Log.e("GCMID",GCMRegistrar.getRegistrationId(this));

    JSONObject post = new JSONObject();
    try {
        post.put("gcmid", regId);
        post.put("deviceid", Settings.Secure.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID));
    } catch (Exception e) {
        e.printStackTrace();
        Toast.makeText(this, "An Error Was encountered connecting to the GCM cloud. Chat will be unavailable",
                Toast.LENGTH_LONG).show();
        return;
    }

    JsonObjectRequest jsObjRequest = new JsonObjectRequest(Request.Method.POST,
            "http://hackedioapp.networksaremadeofstring.co.uk/registergcm.php", post,
            new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {
                    Log.e("response", response.toString());
                    try {
                        if (response.has("success") && response.getBoolean("success")) {
                            //Alls cool
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }, new Response.ErrorListener() {

                @Override
                public void onErrorResponse(VolleyError error) {
                    // TODO Auto-generated method stub
                }
            });

    queue.add(jsObjRequest);
}

From source file:dk.bearware.gui.AudioCodecActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_audiocodec);

    audiocodec = Utils.getAudioCodec(this.getIntent());

    int tab_index = 0;
    switch (audiocodec.nCodec) {
    case Codec.OPUS_CODEC:
        opuscodec = audiocodec.opus;/*w  ww.  j  a v a2 s.c  o  m*/
        tab_index = TAB_OPUS;
        break;
    case Codec.SPEEX_CODEC:
        speexcodec = audiocodec.speex;
        tab_index = TAB_SPEEX;
        break;
    case Codec.SPEEX_VBR_CODEC:
        speexvbrcodec = audiocodec.speex_vbr;
        tab_index = TAB_SPEEXVBR;
        break;
    case Codec.NO_CODEC:
        tab_index = TAB_NOAUDIO;
        break;
    }

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setDisplayHomeAsUpEnabled(true);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by
        // the adapter. Also specify this Activity object, which implements
        // the TabListener interface, as the callback (listener) for when
        // this tab is selected.
        actionBar
                .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }

    mViewPager.setCurrentItem(tab_index);
}

From source file:it.durip_app.TCPActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_graph);
    data = new TCPSource();
    // Get the message from the intent
    isIperfRunning = isIperfRunning();/*from   w w  w .j  a  v a2  s. c o m*/
    Intent intent = getIntent();
    paramUrl = intent.getStringExtra(MainActivity.PARAM_URL);
    paramT = intent.getIntExtra(MainActivity.PARAM_T, 200);
    paramI = intent.getIntExtra(MainActivity.PARAM_I, 5);
    paramPort = intent.getIntExtra(MainActivity.PARAM_PORT, 4000);
    paramSleep = intent.getIntExtra(MainActivity.PARAM_SLEEP, 500);
    paramVerbose = intent.getIntExtra(MainActivity.PARAM_VERBOSE, 1);
    //         frequency = paramPort/1000;
    data.setUrl(paramUrl);
    data.setT(paramT);
    data.setI(paramI);
    data.setPort(paramPort);
    data.setSleep(paramSleep);
    data.setVerbose(paramVerbose);
    data.startTCP();
    // kick off the data generating thread:
    /*
    mySource = new Thread(data);
    mySource.start();
    */
    // Create the adapter that will return a fragment for each of the three primary sections
    // of the app.
    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();

    // Specify that the Home/Up button should not be enabled, since there is no hierarchical
    // parent.
    actionBar.setHomeButtonEnabled(false);

    // Specify that we will be displaying tabs in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Set up the ViewPager, attaching the adapter and setting up a listener for when the
    // user swipes between sections.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAppSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            // When swiping between different app sections, select the corresponding tab.
            // We can also use ActionBar.Tab#select() to do this if we have a reference to the
            // Tab.
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by the adapter.
        // Also specify this Activity object, which implements the TabListener interface, as the
        // listener for when this tab is selected.
        actionBar.addTab(
                actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
    // Show the Up button in the action bar.

}

From source file:com.tabs.viewpager.testt.MainActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Create the adapter that will return a fragment for each of the three primary sections
    // of the app.
    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();

    // Specify that the Home/Up button should not be enabled, since there is no hierarchical
    // parent.//from ww  w  .  ja v  a 2  s  .  c  o m
    actionBar.setHomeButtonEnabled(false);

    // Specify that we will be displaying tabs in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Set up the ViewPager, attaching the adapter and setting up a listener for when the
    // user swipes between sections.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAppSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            // When swiping between different app sections, select the corresponding tab.
            // We can also use ActionBar.Tab#select() to do this if we have a reference to the
            // Tab.
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    //        for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) {
    //            // Create a tab with text corresponding to the page title defined by the adapter.
    //            // Also specify this Activity object, which implements the TabListener interface, as the
    //            // listener for when this tab is selected.
    //            actionBar.addTab(
    //                    actionBar.newTab()
    //                            .setText(mAppSectionsPagerAdapter.getPageTitle(i))
    //                            .setTabListener(this));
    //        }

    //adding tab 1
    actionBar.addTab(actionBar.newTab().setText(R.string.title_orders).setTabListener(this));
    //adding tab 2
    actionBar.addTab(actionBar.newTab().setText(R.string.title_orders).setTabListener(this));
    //adding tab 2
    actionBar.addTab(actionBar.newTab().setText(R.string.title_my_profile).setTabListener(this));
}

From source file:com.afollestad.overhear.ui.OverviewScreen.java

/**
 * Sets up the action bar tabs and the view pager.
 *//*from w  w  w .j av  a 2s  .  c  om*/
private void setupTabs() {
    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    SectionsPagerAdapter mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setOffscreenPageLimit(5);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            getActionBar().setSelectedNavigationItem(position);
        }
    });

    ActionBar.TabListener mTabListener = new ActionBar.TabListener() {
        @Override
        public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {

        }

        @Override
        public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
            invalidateOptionsMenu();
            mViewPager.setCurrentItem(tab.getPosition());
        }

        @Override
        public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) {
            Fragment frag = getFragmentManager().findFragmentByTag("page:" + tab.getPosition());
            if (frag instanceof ListFragment) {
                if (frag.getView() != null)
                    ((ListFragment) frag).getListView().setSelection(0);
            } else if (frag instanceof OverhearGridFragment) {
                if (frag.getView() != null)
                    ((OverhearGridFragment) frag).getListView().setSelection(0);
            }
        }
    };

    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++)
        actionBar.addTab(
                actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(mTabListener));
    actionBar.setSelectedNavigationItem(Store.i(this, "focused_tab", 2));
}

From source file:com.example.swipeuiforupclose.MainActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.profile_main);

    // Create the adapter that will return a fragment for each of the three
    // primary sections
    // of the app.

    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();

    // Specify that the Home/Up button should not be enabled, since there is
    // no hierarchical
    // parent./*from  w ww .j a va 2  s  .  c  om*/
    actionBar.setHomeButtonEnabled(false);
    actionBar.setBackgroundDrawable(new ColorDrawable(0xFF46304e));
    actionBar.setStackedBackgroundDrawable(new ColorDrawable(0xFF573d5d));
    actionBar.setTitle("My Profile");

    // Specify that we will be displaying tabs in the action bar.
    //actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    // Set up the ViewPager, attaching the adapter and setting up a listener
    // for when the
    // user swipes between sections.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAppSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            // When swiping between different app sections, select
            // the corresponding tab.
            // We can also use ActionBar.Tab#select() to do this if
            // we have a reference to the
            // Tab.
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by
        // the adapter.
        // Also specify this Activity object, which implements the
        // TabListener interface, as the
        // listener for when this tab is selected.
        actionBar.addTab(
                actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
}

From source file:it.durip_app.MACActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_mac);
    data = new MACSource();
    isIperfRunning = isIperfRunning();//from   w  w  w . j  a  v a 2 s .co m
    isOlsrRunning = isOlsrRunning();
    // Get the message from the intent
    Intent intent = getIntent();
    paramUrl = intent.getStringExtra(MainActivity.PARAM_URL);
    paramT = intent.getIntExtra(MainActivity.PARAM_T, 200);
    paramI = intent.getIntExtra(MainActivity.PARAM_I, 5);
    paramMAC = intent.getStringExtra(MainActivity.PARAM_MAC);
    paramSleep = intent.getIntExtra(MainActivity.PARAM_SLEEP, 500);
    paramPort = intent.getIntExtra(MainActivity.PARAM_PORT, 4000);
    paramVerbose = intent.getIntExtra(MainActivity.PARAM_VERBOSE, 1);
    data.setUrl(paramUrl);
    data.setT(paramT);
    data.setI(paramI);
    data.setPort(paramPort);
    data.setSleep(paramSleep);
    data.setVerbose(paramVerbose);
    data.setMAC(paramMAC);
    // kick off the data generating thread:
    //mySource = new Thread(data);
    //mySource.start();
    data.startMAC();

    // Create the adapter that will return a fragment for each of the three primary sections
    // of the app.
    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();

    // Specify that the Home/Up button should not be enabled, since there is no hierarchical
    // parent.
    actionBar.setHomeButtonEnabled(false);

    // Specify that we will be displaying tabs in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Set up the ViewPager, attaching the adapter and setting up a listener for when the
    // user swipes between sections.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAppSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            // When swiping between different app sections, select the corresponding tab.
            // We can also use ActionBar.Tab#select() to do this if we have a reference to the
            // Tab.
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by the adapter.
        // Also specify this Activity object, which implements the TabListener interface, as the
        // listener for when this tab is selected.
        actionBar.addTab(
                actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
    // Show the Up button in the action bar.

}