content: package com.example.android.musicstructure.activity;
  
  import android.os.Bundle;
  import android.app.ActionBar;
  import android.app.FragmentTransaction;
  import android.support.v4.app.FragmentActivity;
  import android.support.v4.view.ViewPager;
  
  import com.example.android.musicstructure.R;
  import com.example.android.musicstructure.adapter.TabPagerAdapter;
  
  public class MainActivity extends FragmentActivity {
      ViewPager Tab;
      TabPagerAdapter TabAdapter;
      ActionBar actionBar;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          TabAdapter = new TabPagerAdapter(getSupportFragmentManager());
  
          Tab = (ViewPager) findViewById(R.id.pager);
          Tab.setOnPageChangeListener(
                  new ViewPager.SimpleOnPageChangeListener() {
                      @Override
                      public void onPageSelected(int position) {
                          actionBar = getActionBar();
                          actionBar.setSelectedNavigationItem(position);
                      }
                  });
          Tab.setAdapter(TabAdapter);
  
          actionBar = getActionBar();
          //Enable Tabs on Action Bar
          actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
          ActionBar.TabListener tabListener = new ActionBar.TabListener() {
  
              @Override
              public void onTabReselected(android.app.ActionBar.Tab tab,
                                          FragmentTransaction ft) {
              }
  
              @Override
              public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
                  Tab.setCurrentItem(tab.getPosition());
              }
  
              @Override
              public void onTabUnselected(android.app.ActionBar.Tab tab,
                                          FragmentTransaction ft) {
              }
          };
  
          //Add New Tab
          actionBar.addTab(actionBar.newTab().setText(getString(R.string.tab_playlist)).setTabListener(tabListener));
          actionBar.addTab(actionBar.newTab().setText(getString(R.string.tab_artist)).setTabListener(tabListener));
          actionBar.addTab(actionBar.newTab().setText(getString(R.string.tab_album)).setTabListener(tabListener));
          actionBar.addTab(actionBar.newTab().setText(getString(R.string.tab_song)).setTabListener(tabListener));
  
      }
  
  }