0

I am creating an application using action bar sherlock. My application is using actionbar tabs as navigation mode.

This is my code for the main activity which extends sherlockFragmentActivity:

public class Home extends  SherlockFragmentActivity implements TabListener
{
    ActionBar actionBar;
    enum TabType
    {
        Tab1,Tab2,Tab3,tab4
    }
    private HashMap<TabType, Stack<String>> backStacks;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);
        actionBar = getSupportActionBar();
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        if(savedInstanceState!=null)
        {
            backStacks = (HashMap<TabType, Stack<String>>) savedInstanceState.getSerializable("stacks");
        }
        else
        {
            backStacks = new HashMap<Home.TabType, Stack<String>>();
            backStacks.put(TabType.Tab1, new Stack<String>());
            backStacks.put(TabType.Tab2, new Stack<String>());
            backStacks.put(TabType.Tab3, new Stack<String>());
            backStacks.put(TabType.Tab4, new Stack<String>());

        }
        //creating tabs
        actionBar.addTab(actionBar.newTab().setTag(TabType.Tab1).setIcon(R.drawable.doctor).setTabListener(this));
        actionBar.addTab(actionBar.newTab().setTag(TabType.Tab2).setIcon(R.drawable.appointments).setTabListener(this));
actionBar.addTab(actionBar.newTab().setTag(TabType.Tab3).setIcon(R.drawable.appointments).setTabListener(this));
actionBar.addTab(actionBar.newTab().setTag(TabType.Tab4).setIcon(R.drawable.appointments).setTabListener(this));
    }

But when I build my code, the tabs appear within the action bar itself.

My requirement is the Tabs must come below the ActionBar.

On Mobile the tabs appear below the ActionBar, but when I checked this with a tablet the tabs appear within the action bar, next to my Action bar title. What causes this?

ranjith
  • 4,526
  • 5
  • 27
  • 31

0 Answers0