How to show action bar tabs on different line?

冷暖自知 提交于 2019-12-12 14:16:11

问题


I am using ActionBarTabs to implement 3 tabs in an activity. The tabs display properly in portrait mode below the action bar When I switch to landscape mode, the tabs are placed at the same line with actionbar. How can I force the tabs to display individually in landscape mode ( below the action bar )?

my code is

protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.tabhost_act);

    /* Action Bar Color change on create*/  
    ActionBar actionBar = getActionBar();
    ActionBarColor.setBackgroundColor(actionBar);
    getActionBar().setDisplayHomeAsUpEnabled(true);     
    getActionBar().setTitle(Html.fromHtml("<font color=\"white\" face=\"verdana,arial\">" + getString(R.string.air) + "</font>"));


    // Session Manager
    session = new SessionManager(getApplicationContext());

    /* To Get Unique Device id */
    TelephonyManager TelephonyMgr = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
    szImeiId = TelephonyMgr.getDeviceId(); // Requires READ_PHONE_STATE.

    // get User Details from Session
    HashMap<String, String> hashMap = new HashMap<String, String>();
    hashMap = session.getUserDetails();
    usrNm = hashMap.get(SessionManager.KEY_USRNM);      

    vp = (ViewPager) findViewById(R.id.pager);
    vp.setAdapter(new MyPageAdapter(getSupportFragmentManager()));

    ab = getActionBar();


    ActionBar.Tab tab1 = ab.newTab();
    tab1.setText("INFO");
    tab1.setTabListener(this);


    ActionBar.Tab tab2 = ab.newTab();
    tab2.setText("PORT");
    tab2.setTabListener(this);

    ActionBar.Tab tab3 = ab.newTab();
    tab3.setText("PACKAGES");
    tab3.setTabListener(this);

    ab.addTab(tab1);
    ab.addTab(tab2);
    ab.addTab(tab3);    
    ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);<--used bt not working 

    // for calling fragment instnace 
    adapter=new MyPageAdapter(getSupportFragmentManager());
    vp.setAdapter(adapter);


}

refered same question Link

<com.eanda.frete_sales.common.utils.NonSwipeableViewPager xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" 
    style="@style/My.TabText.Style">

</com.eanda.frete_sales.common.utils.NonSwipeableViewPager>

来源:https://stackoverflow.com/questions/21402936/how-to-show-action-bar-tabs-on-different-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!