android - 底部的 ActionBar Sherlock Tabs

标签 android tabs actionbarsherlock

这可能吗?

我可以使用 fragment ,我可以将选项卡放在底部,但我不能使用 ActionBar Sherlock。有人知道怎么做吗?

我正在使用类似这样的方法来使用选项卡(它们在底部):

tHost = (TabHost) findViewById(R.id.tabhost2);

    tHost.setup();

    tM = new TabManager(this, tHost, android.R.id.tabcontent);

    tM.addTab(tHost.newTabSpec("tabCREATE").setIndicator("Criar"),
            Criar.CountingFragment.class, null);

    tM.addTab(tHost.newTabSpec("tabCREATE2").setIndicator("Criar2"),
            Criar.CountingFragment.class, null);

如何将其更改为 ActionBar 选项卡?

我通常将其用于操作栏:

getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    for (int i = 1; i <= 3; i++) {
        ActionBar.Tab tab = getSupportActionBar().newTab();
        if (i == 1) {
            tab.setText("a");
        }
        else if(i == 2)
            tab.setText("b");
        else if (i == 3)
            tab.setText("c");
        tab.setTabListener(this);
        getSupportActionBar().addTab(tab);

这很好,但我真的需要把它放在底部。是否可以在第二种方法上设置 Tabhost?如何?我相信它会解决我所有的问题。

最佳答案

在您的 list 中添加此代码 android:uiOptions="splitActionBarWhenNarrow"

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          android:uiOptions="splitActionBarWhenNarrow"
          android:versionCode="431"
          android:versionName="4.3.1"
          package="com.actionbarsherlock.sample.demos">

然后在您的 Activity 中再次添加此代码

<activity android:label="@string/activity_name" 
          android:uiOptions="splitActionBarWhenNarrow"
          android:name=".SampleList" android:theme="@style/Theme.Sherlock">

我试过 sample ,它可以正常工作

关于android - 底部的 ActionBar Sherlock Tabs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14133850/

相关文章:

android - 在特定时间在android中启动音频剪辑

java - BB 7.0 中的 Blackberry Java 选项卡

java - 在 jTable 上使用 Enter 键就像 Tab 键

Android:不会从 fragment 调用 onOptionsItemSelected

android - 错误 : Attribute "title" has already been defined

android - Camera2 Api android 上的 ImageReader

android - 如何比较设置时间和实际时间?

android - 在具有 MenuItem.SHOW_AS_ACTION_ALWAYS 的 ActionBarSherlock 中将 TextWatcher 添加到 EditText

java - 错误 Gradle 同步失败 : For input string: "12" when apply plugin: 'com.google.gms.google-services'

带 Rails 的 JQuery 选项卡 : replacing tab content