2013-01-03 126 views
5

可能吗?底部的ActionBar Sherlock标签

我可以使用片段,我可以把标签放在底部,但我不能用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); 

我怎样才能将其更改为动作条选项卡?

我通常使用本作的动作条:

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?如何?我相信它会解决我所有的问题。

+0

我认为这是你正在寻找的:http://stackoverflow.com/a/8468675/33203 – ashokgelal

+0

不,我想要做的就是把ActionBarSherlock的标签放在底部。 –

+0

您无法通过操作栏执行此操作。如果你真的觉得有必要违背操作系统的设计准则,那么你可以使用'LinearLayout'和'android:layout_weight'重新创建一个操作栏的外观和感觉。 – edthethird

回答

0

在你的清单中添加该代码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 android:label="@string/activity_name" 
      android:uiOptions="splitActionBarWhenNarrow" 
      android:name=".SampleList" android:theme="@style/Theme.Sherlock"> 

我试图在样品和它的作品就可以了