Android将tabOrder从右向左设置或更改方向

Android将tabOrder从右向左设置或更改方向,android,android-layout,android-fragments,Android,Android Layout,Android Fragments,我的代码中的默认订单选项卡是从左到右,我想将其更改为从右到左或将该方向更改为向右 我的代码: /* * TAB LISTENER ON ----------------------- */ final ActionBar actionBar = getSupportActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); //--------- TAB 1

我的代码中的默认订单选项卡是从左到右,我想将其更改为从右到左或将该方向更改为向右

我的代码:

    /*
    * TAB LISTENER ON -----------------------
    */
    final ActionBar actionBar = getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    //--------- TAB 1
    ActionBar.Tab tab1 = actionBar.newTab();
    tab1.setTabListener(this);
    tab1.setIcon(R.drawable.abc_ic_voice_search);
    actionBar.addTab(tab1);

    //--------- TAB 2
    ActionBar.Tab tab2 = actionBar.newTab();
    tab2.setIcon(R.drawable.ic_drawer);

    tab2.setTabListener(this);
    actionBar.addTab(tab2);

    //--------- TAB 3
    ActionBar.Tab tab3 = actionBar.newTab();
    tab3.setText(R.string.title_section3);
    tab3.setTabListener(this);
    actionBar.addTab(tab3);
导航抽屉片段XML:

<ListView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#cccc"
    android:choiceMode="singleChoice"
    android:divider="@android:color/transparent"
    android:dividerHeight="0dp"
    tools:context="ir.tsms.NavigationDrawerFragment" />
<!-- A DrawerLayout is intended to be used as the top-level content view using match_parent for both width and height to consume the full space available. -->

<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="ir.tsms.MainActivity" >

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
   </android.support.v4.view.ViewPager>

    <fragment
        android:id="@+id/navigation_drawer"
        android:name="ir.tsms.NavigationDrawerFragment"
        android:layout_width="@dimen/navigation_drawer_width"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        tools:layout="@layout/fragment_navigation_drawer" />

</android.support.v4.widget.DrawerLayout>

片段\u主XML:

<ListView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#cccc"
    android:choiceMode="singleChoice"
    android:divider="@android:color/transparent"
    android:dividerHeight="0dp"
    tools:context="ir.tsms.NavigationDrawerFragment" />
<!-- A DrawerLayout is intended to be used as the top-level content view using match_parent for both width and height to consume the full space available. -->

<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="ir.tsms.MainActivity" >

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
   </android.support.v4.view.ViewPager>

    <fragment
        android:id="@+id/navigation_drawer"
        android:name="ir.tsms.NavigationDrawerFragment"
        android:layout_width="@dimen/navigation_drawer_width"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        tools:layout="@layout/fragment_navigation_drawer" />

</android.support.v4.widget.DrawerLayout>

如果tab3是您的第一个选项卡,则在添加任何其他选项卡之前,首先将tab3添加到操作栏

actionbar.addTab (tab1, true);

这可用于将选项卡设置为选中状态

如果tab3是您的第一个选项卡,则在添加任何其他选项卡之前,先将tab3添加到操作栏

actionbar.addTab (tab1, true);
这可用于将选项卡设置为选中状态

将最后一个选项卡添加为:

actionBar.addTab(tab3, true);
因此,它将被选中。

将您的最后一个选项卡添加为:

actionBar.addTab(tab3, true);

所以它将被选中。

除非我在你的问题中遗漏了什么,您只需更改在code.add tab中调用
actionBar.addTab
的顺序,将tab反向添加到actionBar即可order@AshaSoman我可以自定义订单吗?自定义订单是什么意思?如果tab3是第一个选项卡,那么在添加任何其他选项卡之前,首先将tab3添加到操作栏tabs@AshaSoman没错。我想在默认情况下激活或启用last。在这个动作中,第一个标签是活动的,除非我在你的问题中遗漏了什么,您只需更改在code.add tab中调用
actionBar.addTab
的顺序,将tab反向添加到actionBar即可order@AshaSoman我可以自定义订单吗?自定义订单是什么意思?如果tab3是第一个选项卡,那么在添加任何其他选项卡之前,首先将tab3添加到操作栏tabs@AshaSoman没错。我想在默认情况下激活或启用last。在此操作中,第一个选项卡处于活动状态