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:com.dvdprime.mobile.android.ui.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.
    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/*from   w w w. j a v a  2  s  .c o m*/
        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);
            EasyTracker.getTracker().sendView(AppSectionsPagerAdapter.tabEngTitles[position]);
            LOGD("Tracker", AppSectionsPagerAdapter.tabEngTitles[position]);
            // Save position value in preference
            PrefUtil.getInstance().setInt(PrefKeys.LAST_TAB_POSITION, 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));
    }

    // Google Analytics
    EasyTracker.getInstance().setContext(this);
    EasyTracker.getTracker().sendView("Main");
    LOGD("Tracker", "Main");

    // Set Last Tab
    lastPosition = PrefUtil.getInstance().getInt(PrefKeys.LAST_TAB_POSITION, 0);
    actionBar.setSelectedNavigationItem(lastPosition);

    //  .
    if (PrefUtil.getInstance().getString(PrefKeys.ACCOUNT_ID, null) != null) {
        JsonObjectRequest filterReq = new JsonObjectRequest(
                StringUtil.format(Config.MOBILE_DP_COUNT,
                        PrefUtil.getInstance().getString(PrefKeys.ACCOUNT_ID, null)),
                null, createJsonReqSuccessListener(), createJsonReqErrorListener());
        filterReq.setTag(TAG);
        DpApp.getRequestQueue().add(filterReq);
    }

    //   ?
    if (SystemUtil.getVersionName(this).equals("1.0")
            && PrefUtil.getInstance().getBoolean(PrefKeys.VERSION_1_0, true)) {
        String msg = new StringBuffer().append("[1.0 ]\n\n").append(
                "-?   \n  ? ?? ?  ? ?? /?.\n\n")
                .append("-   \n  ?  ?    ?. ?  ? ?.")
                .toString();
        new AlertDialog.Builder(this).setTitle(getString(R.string.alert_dialog_version)).setMessage(msg)
                .setCancelable(false)
                .setPositiveButton(getString(R.string.alert_dialog_ok), new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        PrefUtil.getInstance().setBoolean(PrefKeys.VERSION_1_0, false);
                        dialog.dismiss();
                    }
                }).create().show();
    }
}

From source file:give_me_coins.dashboard.MainScreen.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main_screen);

    //create file for shared preference
    sharedPref = getSharedPreferences(getString(R.string.preference_file_key), Context.MODE_PRIVATE);

    API_key_saved = sharedPref.getString(getString(R.string.saved_api_key), "");
    if (sharedPref.getBoolean(getString(R.string.show_ltc), true)) {
        coin_select = 1;//from w  ww .j  a v a  2 s.co m
    } else if (sharedPref.getBoolean(getString(R.string.show_btc), true)) {
        coin_select = 2;
    } else if (sharedPref.getBoolean(getString(R.string.show_ftc), true)) {
        coin_select = 3;
    }

    // Start service to receive data
    //if(mService==null) mService= new GMCService(this,mHandler);
    if (mPoolService == null)
        mPoolService = new GMCPoolService(mHandler);

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

    mViewPager = (ViewPager) findViewById(R.id.pager);

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

    // Specify that tabs should be displayed in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // For each of the sections in the app, add a tab to the action bar.
    // 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("Settings")
            //.setIcon(R.drawable.settings)
            .setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText("Summary")
            // .setIcon(R.drawable.dashboard)
            .setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText("Pool")
            //.setIcon(R.drawable.news)
            .setTabListener(this));

    // Set up the ViewPager, attaching the adapter and setting up a listener for when the
    // user swipes between sections.
    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);
        }
    });

    actionBar.setBackgroundDrawable(new ColorDrawable(R.color.menu_background));

    // mViewPager.setCurrentItem(0);
    if (API_key_saved != null && !API_key_saved.equals("")) {
        if (!"No api key found".equals(API_key_saved)) {
            startService();
            // change to summary tab if api key is set and everything
            mViewPager.setCurrentItem(1);
        }
    }

}

From source file:com.example.jenil.parsedemo.GamePlayActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
    setContentView(R.layout.activity_game_play);

    Intent intent = getIntent();// www. ja  v a 2s .co  m
    Phrase = intent.getStringExtra("MOVIE");
    words = Phrase.split(" ");

    opponent = intent.getStringExtra("OPPONENT");

    // 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();

    if (actionBar == null) {
        Log.i("ALERT", "NULL");
    } else {
        Log.i("ALERT", "NOT NULL");
    }

    // 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() - 1; 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));
    }
    actionBar.addTab(actionBar.newTab().setText("Submit").setTabListener(this));

}

From source file:com.denel.facepatrol.MainActivity.java

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

    mycontext = getApplicationContext();

    // 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.//  w  ww  .j a va 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));
    }
}

From source file:com.manoj.macawplayer.SwipeViewActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTheme(R.drawable.theme_skyblue);//from   w ww  .j ava2  s . c  o m
    requestWindowFeature(Window.FEATURE_ACTION_BAR);
    setContentView(R.layout.swipe_view);
    int actionBarTitleId = Resources.getSystem().getIdentifier("action_bar_title", "id", "android");
    TextView actionBarTextView = (TextView) findViewById(actionBarTitleId);

    if (actionBarTextView != null) {
        Log.i("actionBarTextView :", "not null");
        actionBarTextView.setTextColor(Color.GREEN);
    } else
        Log.i("actionBarTextView :", "null");

    // 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);

    //to remove the title and icon above the action bar
    getActionBar().setDisplayShowTitleEnabled(false);
    getActionBar().setDisplayShowHomeEnabled(false);

    // 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);
    LinearLayout homeScreen = (LinearLayout) findViewById(R.id.swipeviewl);
    utilities = new Utilities();
    utilities.colorSeter(homeScreen, getApplicationContext());

    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));
        /*Tab tab = actionBar.getTabAt(i);
        View v  = tab.setgetCustomView();
        v.setBackgroundResource(R.drawable.theme_skyblue);*/
    }
}

From source file:org.ounl.lifelonglearninghub.nfcecology.fcube.navigate.SwipeFragmentActivity.java

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

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

    // Actvate home button
    final ActionBar actionBar = getActionBar();
    actionBar.setHomeButtonEnabled(true);

    // 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//from  w ww  .  j  av a  2s. c  o m
        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:com.example.bijesh.mycollege10.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();
    //action bar color
    actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar));
    //tab color//from www . ja  v a  2  s .c o  m
    //   actionBar.setStackedBackgroundDrawable(getResources().getDrawable(R.drawable.bluewall));
    //tab background color
    //        actionBar.setStackedBackgroundDrawable(getResources().getDrawable(
    // R.drawable.greenwall));

    // 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));
    }
}

From source file:com.packetsender.android.MainActivity.java

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

    mContext = getApplicationContext();//from   w  w w  . j  a  v a2  s  . co m
    serviceIntent = new Intent(mContext, PacketListenerService.class);
    activeMenu = R.menu.packetlistmenu;

    trafficLogPackets = new ArrayList<Packet>();

    dataStore = new DataStorage(getSharedPreferences(DataStorage.PREFS_SETTINGS_NAME, 0),
            getSharedPreferences(DataStorage.PREFS_SAVEDPACKETS_NAME, 0),
            getSharedPreferences(DataStorage.PREFS_SERVICELOG_NAME, 0),
            getSharedPreferences(DataStorage.PREFS_MAINTRAFFICLOG_NAME, 0));

    dataStore.clearServicePackets();

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

    // 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));
    }

    startListenerService();

    wifiActive = DataStorage.isWifiActive(mContext);
    ipAddress = "";

    if (wifiActive) {
        ipAddress = DataStorage.getIP(mContext);
        Toast.makeText(mContext, "Your IP is " + ipAddress, Toast.LENGTH_LONG).show();
    } else {
        Toast.makeText(mContext, "Send only. Wifi is inactive.", Toast.LENGTH_LONG).show();
    }

    //periodically poll the traffic log

    trafficLogPolling = new Runnable() {
        public void run() {

            String msg = dataStore.getToast();
            if (!msg.isEmpty()) {
                Toast.makeText(mContext, msg, Toast.LENGTH_LONG).show();
            }

            Packet[] trafficPackets = dataStore.fetchAllTrafficLogPackets();
            if (trafficPackets.length != trafficLogPackets.size()) {
                trafficLogPackets.clear();
                trafficLogPackets.addAll(Arrays.asList(trafficPackets));
                updateTrafficPacketsList(trafficFragmentView);
                //trafficFragmentView

            }

            //Log.d("main", DataStorage.FILE_LINE( "trafficLogPolling."));
            mHandler.postDelayed(trafficLogPolling, 1100);
        }
    };

    //periodically monitor Wi-Fi
    updateWifi = new Runnable() {
        public void run() {

            boolean checkWifi = DataStorage.isWifiActive(mContext);
            if (checkWifi != wifiActive) {
                if (checkWifi) {
                    ipAddress = DataStorage.getIP(mContext);
                    Toast.makeText(mContext, "Your IP is " + ipAddress, Toast.LENGTH_LONG).show();
                } else {
                    Toast.makeText(mContext, "Wifi is not active", Toast.LENGTH_LONG).show();
                }

                wifiActive = checkWifi;

            }
            mHandler.postDelayed(updateWifi, 5000);
        }
    };

    mHandler.postDelayed(updateWifi, 5000);
    mHandler.postDelayed(trafficLogPolling, 700);
    //setup saved List periodic check
    updateSavedLists = new Runnable() {
        public void run() {
            if (dataStore.isInvalidateLists()) {

                Log.d("main", DataStorage.FILE_LINE("Found invalid lists."));
                updateSavedPacketsList(packetsFragmentView);
                dataStore.clearInvalidateLists();
            }

            mHandler.postDelayed(updateSavedLists, 2000);
        }
    };

    mHandler.postDelayed(updateSavedLists, 7000);

}

From source file:no.invisibleink.app.MainActivity.java

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

    /* -------------------------------- Init ---------------- */
    serverManager = new ServerManager();
    locationManager = new LocationManager(this);
    locationManager.onCreate();//  w  ww . ja  v a2 s . co m

    /* -------------------------------- Swipe view with taps ---------------- */
    fragmentManager = getSupportFragmentManager();

    listSectionFragment = new ListViewFragment();
    mapSectionFragment = new MapViewFragment();
    postSectionFragment = new PostViewFragment();

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

    // 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);
        }
    });
    /*
     * Set the number of pages that should be retained to either side of the
     * current page in the view hierarchy in an idle state. Pages beyond
     * this limit will be recreated from the adapter when needed.
     */
    mViewPager.setOffscreenPageLimit(3);

    // 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));
    }

    try {
        MapsInitializer.initialize(getApplicationContext());
    } catch (GooglePlayServicesNotAvailableException e) {
        Log.e(TAG, "Google play services is not available.");
    }
}