title: Change Action bar title for each tab swipe on android
body: <p>I have set up Action bar with swipe tabs using ActionBarSherlock and Fragments. </p>
  
  <p>I want to have different Action bar title for each tab. And it would be great if i could set up image instead of the title, so each tab would have different Action bar image title.</p>
  
  <p>I would appreciate any suggestions and links to tutorials! Thanks:)</p>
  
  <p>here is my code:
  TabActivity.java</p>
  
  <pre><code>package com.tptabs;
  
  import android.os.Bundle;
  import android.app.Activity;
  import android.view.Menu;
  
  import com.actionbarsherlock.app.ActionBar;
  import com.actionbarsherlock.app.SherlockFragmentActivity;
  
  import android.support.v4.view.ViewPager;
  
  public class TabActivity extends SherlockFragmentActivity {
  
      private ViewPager mViewPager;
      private TabAdapter mTabsAdapter;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          mViewPager = new ViewPager(this);
          mViewPager.setId(R.id.pager);
          setContentView(mViewPager);
  
          final ActionBar bar = getSupportActionBar();
          bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
  
          mTabsAdapter = new TabAdapter(this, mViewPager);
          mTabsAdapter.addTab(bar.newTab().setText("").setIcon(getResources().getDrawable(R.drawable.social_group)), JoinFragment.class, null);
          mTabsAdapter.addTab(bar.newTab().setText("").setIcon(getResources().getDrawable(R.drawable.content_edit)), CreateFragment.class, null);
          mTabsAdapter.addTab(bar.newTab().setText("").setIcon(getResources().getDrawable(R.drawable.location_web_site)), PlayFragment.class, null);
          mTabsAdapter.addTab(bar.newTab().setText("").setIcon(getResources().getDrawable(R.drawable.collections_collection)), ResultFragment.class, null);
          mTabsAdapter.addTab(bar.newTab().setText("").setIcon(getResources().getDrawable(R.drawable.device_access_accounts)), StoreFragment.class, null);
      }
  }
  </code></pre>
  
  <p>TabAdapter.java</p>
  
  <pre><code>package com.tptabs;
  import java.util.ArrayList;
  
  import android.content.Context;
  import android.os.Bundle;
  import android.support.v4.app.Fragment;
  import android.support.v4.app.FragmentPagerAdapter;
  import android.support.v4.app.FragmentTransaction;
  import android.support.v4.view.ViewPager;
  import android.util.Log;
  import android.widget.Toast;
  
  import com.actionbarsherlock.app.ActionBar;
  import com.actionbarsherlock.app.ActionBar.Tab;
  import com.actionbarsherlock.app.SherlockFragmentActivity;
  
  public class TabAdapter extends FragmentPagerAdapter implements ActionBar.TabListener , ViewPager.OnPageChangeListener{
      private final Context mContext;
      private final ActionBar mActionBar;
      private final ViewPager mViewPager;
      private final ArrayList&lt;TabInfo&gt; mTabs = new ArrayList&lt;TabInfo&gt;();
      private final String TAG = "21st Polling:";
  
      static final class TabInfo{
          private final Class&lt;?&gt; clss;
          private final Bundle args;
  
          TabInfo(Class&lt;?&gt; _class, Bundle _args){
              clss = _class;
              args = _args;
          }
      }
  
      public TabAdapter(SherlockFragmentActivity fa, ViewPager pager) {
          super(fa.getSupportFragmentManager());
          mContext = fa;
          mActionBar = fa.getSupportActionBar();
          mViewPager = pager;
          mViewPager.setAdapter(this);
          mViewPager.setOnPageChangeListener(this);
      }
  
      public void addTab(ActionBar.Tab tab, Class&lt;?&gt; clss, Bundle args){
          TabInfo info = new TabInfo(clss, args);
          tab.setTag(info);
          tab.setTabListener(this);
          mTabs.add(info);
          mActionBar.addTab(tab);
          notifyDataSetChanged();
      }
  
      @Override
      public void onPageScrollStateChanged(int state) {
  
  
      }
  
      @Override
      public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
  
  
      }
  
      @Override
      public void onPageSelected(int position) {
          mActionBar.setSelectedNavigationItem(position);
                  }
  
      @Override
      public  void onTabSelected(Tab tab, FragmentTransaction ft) {
          mViewPager.setCurrentItem(tab.getPosition());
          Log.v(TAG, "clicked");
          Object tag = tab.getTag();
          for (int i = 0; i&lt;mTabs.size(); i++){
              if (mTabs.get(i) == tag){
                  mViewPager.setCurrentItem(i);
              }
          }
  
      }
  
      @Override
      public void onTabUnselected(Tab tab, FragmentTransaction ft) {
          //Toast.makeText(mContext, "You've deselected a tab", Toast.LENGTH_SHORT).show();
      }
  
      @Override
      public void onTabReselected(Tab tab, FragmentTransaction ft) {
  
      }
  
      @Override
      public Fragment getItem(int position) {
          TabInfo info = mTabs.get(position);
          return Fragment.instantiate(mContext, info.clss.getName(), info.args);
      }
  
      @Override
      public int getCount() {
          return mTabs.size();
      }
  
  }
  </code></pre>