如何在不同的行上显示操作栏选项卡?

2023-12-30

我正在使用 ActionBarTabs 在活动中实现 3 个选项卡。选项卡在操作栏下方的纵向模式下正确显示当我切换到横向模式时,选项卡与操作栏放置在同一行。如何强制选项卡以横向模式单独显示(位于操作栏下方)?

我的代码是

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);


}

提到了同样的问题Link https://stackoverflow.com/questions/17200952/actionbarsherlock-tabs-in-landscape-orientation

<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>

None

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何在不同的行上显示操作栏选项卡? 的相关文章

随机推荐