我想創建ActionBar
配合圖標,標籤和菜單按鈕在同一行,但通過下面的代碼,我得到2線爲上PRINTSCREEN:動作條與圖標,標籤和菜單按鈕在一行
的java:
viewPager = (ViewPager) findViewById(R.id.pager);
bar = getSupportActionBar();
bar.setIcon(R.drawable.ic_map);
bar.setDisplayShowHomeEnabled(false);
bar.setDisplayShowTitleEnabled(false);
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
TabsAdapter tabsAdapter = new TabsAdapter(this, viewPager);
tabsAdapter.addTab(bar.newTab().setText("A"), ClientTemplates.class, null);
tabsAdapter.addTab(bar.newTab().setText("B"), ClientWalletsCards.class, null);
tabsAdapter.addTab(bar.newTab().setText("C"), ClientReports.class, null);
XML:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:paddingRight="1px"
android:paddingLeft="1px"/>
我必須在只有1行的代碼中更改什麼?
應該指出的是,這種行爲(標籤出現在操作欄上方)是一個錯誤Android系統。爲了一致性,ActionBarSherlock反映了這個錯誤。 –