gpt4 book ai didi

Android 设置选项卡从右到左顺序或改变方向

转载 作者:行者123 更新时间:2023-11-29 15:59:30 25 4
gpt4 key购买 nike

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

我的代码:

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

NavigationDrawerFragment 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" />

fragment_main XML:

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

actionbar.addTab (tab1, true);

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

关于Android 设置选项卡从右到左顺序或改变方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25377773/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com