2

what I need to do is have the tab below the action bar, how is this possible? I tried following all the tutorials and even though in the tutorials' screen shots it appears to be below the action bar in my device (a Samsung Galaxy Tab) it appears beside the logo like this:

enter image description here

Here's my code:

public class Yab extends Activity implements ActionBar.TabListener{


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

    getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
    setContentView(R.layout.activity_yab);


    RelativeLayout custom = new RelativeLayout(getApplicationContext());
    ActionBar.LayoutParams params = new ActionBar.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    custom.setLayoutParams(params); 
    custom.setGravity(Gravity.CENTER);
    ActionBar actionBar = getActionBar();

    // add the custom view to the action bar
    //actionBar.setCustomView(R.layout.activity_yab);

    actionBar.show();

    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setCustomView(custom);

    actionBar.setTitle("Trial");
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);


    // For each of the sections in the app, add a tab to the action bar.
    actionBar.addTab(actionBar.newTab().setText("add")
        .setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText("delete")
        .setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText("view")
        .setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText("view2")
            .setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText("view3")
            .setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText("view4")
            .setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText("view5")
            .setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText("view6")
            .setTabListener(this));
    //actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM
      //  | ActionBar.DISPLAY_SHOW_HOME);
  }





@Override
  public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu, menu);
    return true;
  }
}

How can I move the position of the tabs to be below the action bar? Any suggestions are really appreciated! Thanks in advance.

Salma
  • 113
  • 3
  • 9
  • [Take a look at this](http://stackoverflow.com/questions/13828659/how-to-stop-actionbar-tab-navigation-to-display-as-a-spinner-when-it-gets-too-lo/13828869#13828869) – Ahmad May 28 '13 at 22:35
  • Where should I put it (false )?? I'm kinda new to this =s – Salma May 28 '13 at 22:39
  • Into your values-480dp/styles.xml. You may have to create this folder and file. You also have to create a style in which you can put in these attributes. – Ahmad May 28 '13 at 22:44
  • Okay, I then need to have my actionbar use this style right? if so, how? Thank you for your patience. – Salma May 28 '13 at 22:46
  • I'm sorry but when I try to do this: I get an error that – Salma May 28 '13 at 23:07
  • Sorry I mixed something up. You don't have to put that in styles.xml. Just create a bools.xml file in values-480dp and paste those boolean values in there. Sorry. – Ahmad May 28 '13 at 23:16
  • Don't worry about it! I did what you said now but I'm afraid that it's not working either, the tabs are still beside the logo. – Salma May 28 '13 at 23:25
  • Hmm, like I already said in the linked post, it is intend to be this way (http://code.google.com/p/android/issues/detail?id=24439) so this trick might not always work. – Ahmad May 28 '13 at 23:29
  • Okay, thanks for your efforts! – Salma May 28 '13 at 23:32

0 Answers0