http://i.stack.imgur.com/cbdyv.jpg合併的Android選項菜單與動作條
似乎無法找到這個問題的答案。我已經爲文件選項嘗試了各種不同的android標籤。
我知道,你可以設置 機器人:uiOptions =「splitActionBarWhenNarrow」在您的清單
但只是把該選項在屏幕的底部。
理想我想有,TAB1 TAB2 TAB3 TAB4:< - (三聯點溢出)
出於某種原因,我的應用程序創建我與它的三倍點動作欄下面這個新的酒吧?
這是我的代碼
艙單
<uses-sdk android:minSdkVersion="14" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.Holo" >
<activity
android:name=".TestForActionBarActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
main_options.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/file"
android:title="File" >
</item>
</menu>
活動 包test.actionbar;
public class TestForActionBarActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
ActionBar.Tab tab1 = actionBar.newTab().setText("Tab 1");
tab1.setTabListener(new TabListener(){
public void onTabReselected(Tab tab, FragmentTransaction ft) {
// TODO Auto-generated method stub
}
public void onTabSelected(Tab tab, FragmentTransaction ft) {
// TODO Auto-generated method stub
}
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
// TODO Auto-generated method stub
}});
actionBar.addTab(tab1);
ActionBar.Tab tab2 = actionBar.newTab().setText("Tab 2");
tab2.setTabListener(new TabListener(){
public void onTabReselected(Tab tab, FragmentTransaction ft) {
// TODO Auto-generated method stub
}
public void onTabSelected(Tab tab, FragmentTransaction ft) {
// TODO Auto-generated method stub
}
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
// TODO Auto-generated method stub
}});
actionBar.addTab(tab2);
ActionBar.Tab tab3 = actionBar.newTab().setText("Tab 3");
tab3.setTabListener(new TabListener(){
public void onTabReselected(Tab tab, FragmentTransaction ft) {
// TODO Auto-generated method stub
}
public void onTabSelected(Tab tab, FragmentTransaction ft) {
// TODO Auto-generated method stub
}
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
// TODO Auto-generated method stub
}});
actionBar.addTab(tab3);
ActionBar.Tab tab4 = actionBar.newTab().setText("Tab 4");
tab4.setTabListener(new TabListener(){
public void onTabReselected(Tab tab, FragmentTransaction ft) {
// TODO Auto-generated method stub
}
public void onTabSelected(Tab tab, FragmentTransaction ft) {
// TODO Auto-generated method stub
}
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
// TODO Auto-generated method stub
}});
actionBar.addTab(tab4);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.layout.main_options, menu);
return true;
}
}