Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8922759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:55:33+00:00 2026-06-15T06:55:33+00:00

I am trying to implement ActionBar Sherlock with Tabs below that as shown in

  • 0

enter image description here

I am trying to implement ActionBar Sherlock with Tabs below that as shown in the above wire-frame.

Should i use TabActivity ? – since i saw that it is deprecated. Which is the best way to achieve the same.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T06:55:35+00:00Added an answer on June 15, 2026 at 6:55 am

    I implemented this functionality with a SherlockFragmentActivity as tabview container and with SherlockFragment as tabs. Here is a sketch (I omitted the usual Android activity stuff):

    This is the tabview activity with two tabs:

    public class TabViewActivity extends SherlockFragmentActivity {
      // store the active tab here
      public static String ACTIVE_TAB = "activeTab";
    
      @Override
      public void onCreate(Bundle savedInstanceState) {
        ..
        final ActionBar actionBar = getSupportActionBar();
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        // add the first tab which is an instance of TabFragment1
        Tab tab1 = actionBar.newTab()
                  .setText("TabTitle1")
                  .setTabListener(new TabListener<TabFragment1>(
                   this, "tab1", TabFragment1.class));
        actionBar.addTab(tab1);
    
        // add the second tab which is an instance of TabFragment2
        Tab tab2 = actionBar.newTab()
               .setText("TabTitle2")
               .setTabListener(new TabListener<TabFragment2>(
                    this, "tab2", TabFragment2.class));
        actionBar.addTab(tab2);
    
        // check if there is a saved state to select active tab
        if( savedInstanceState != null ){
          getSupportActionBar().setSelectedNavigationItem(
                      savedInstanceState.getInt(ACTIVE_TAB));
        }
      }
    
      @Override
      protected void onSaveInstanceState(Bundle outState) {
        // save active tab
        outState.putInt(ACTIVE_TAB,
                getSupportActionBar().getSelectedNavigationIndex());
        super.onSaveInstanceState(outState);
      }
    }
    

    And this is the TabFragment that holds a tab’s content:

    public class TabFragment extends SherlockFragment {
      // your member variables here
      @Override
      public View onCreateView(LayoutInflater inflater, 
                     ViewGroup container, Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_va_esh, container, false);
        ... // do your view initialization here
        return view;
      }
    
    }
    

    And finally this is the TabListener that handles tab switches:

    public class TabListener<T extends Fragment> implements ActionBar.TabListener{
      private TabFragment mFragment;
      private final Activity mActivity;
      private final String mTag;
      private final Class<T> mClass;
    
      public TabListener(Activity activity, String tag, Class<T> clz) {
        mActivity = activity;
        mTag = tag;
        mClass = clz;
      }
    
      public void onTabSelected(Tab tab, FragmentTransaction ft) {
        // Check if the fragment is already initialized
        if (mFragment == null) {
          // If not, instantiate and add it to the activity
          mFragment = (TabFragment) Fragment.instantiate(
                            mActivity, mClass.getName());
          mFragment.setProviderId(mTag); // id for event provider
          ft.add(android.R.id.content, mFragment, mTag);
        } else {
          // If it exists, simply attach it in order to show it
          ft.attach(mFragment);
        }
    
      }
    
      public void onTabUnselected(Tab tab, FragmentTransaction ft) {
        if (mFragment != null) {
          // Detach the fragment, because another one is being attached
          ft.detach(mFragment);
        }
      }
    
      public void onTabReselected(Tab tab, FragmentTransaction ft) {
        // User selected the already selected tab. Usually do nothing.
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement sherlock actionbar but i can't set the right theme in
Ok, so I'm trying to use Sherlock to display multiple tabs, each for one
I'm currently trying to implements a greendroid ActionBar that have a ActivityGroup below it.
As topic states I'm trying to implement swipable tabs using Fragments and ActionBar. I've
I'm trying to make use of Actionbar Sherlock 4, targeting sdk 15 and min
I am trying to implement Action Bar using ActionBar Sherlock. I have three Action
Trying to implement LoaderManager + CursorLoader. In onFinish method adapter should swap its cursor
I'm trying implement server code of Server-Sent Events in a generic way that any
Trying to implement a function that will return a list of ints the represent
I'm implementing some code from an example (http://arvid-g.de/12/android-4-actionbar-with-tabs-example) and trying to convert it to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.