我使用ActionBarSherlock实施的一项活动4个选项卡。在操作栏下方肖像模式和滚动的作品,因为它应该在标签显示正常。当我切换到横向模式时,标签被放置在一个微调(他们还会正常运行)。我怎么能强制标签,以显示各自在横向模式下(无论是在操作栏或以下)?
getSupportActionBar()setNavigationMode(ActionBar.NAVIGATION_MODE_TABS)。 getSupportActionBar()setDisplayHomeAsUpEnabled(真)。 ActionBar.Tab TAB1 = getSupportActionBar()newTab()。 tab1.setText(TAB 1 TEXT); tab1.setTabListener(本); 。getSupportActionBar()addTab(TAB1); ActionBar.Tab TAB2 = getSupportActionBar()newTab()。 tab2.setText(TAB 2 TEXT); tab2.setTabListener(本); 。getSupportActionBar()addTab(TAB2); ActionBar.Tab TAB3 = getSupportActionBar()newTab()。 tab3.setText(TAB 3 TEXT); tab3.setTabListener(本); 。getSupportActionBar()addTab(TAB3); ActionBar.Tab TAB4 = getSupportActionBar()newTab()。 tab4.setText(TAB 4 TEXT); tab4.setTabListener(本); 。getSupportActionBar()addTab(TAB4);
解决方案
这是动作条的默认行为。
HTTPS://$c$c.google。 COM / p /安卓/问题/细节?ID = 24439
我看到这个
的https://groups.google.com/forum/#!msg/android-developers/2unF5lKfn64/iKUX7JbbOo4J
添加标签来动作条通话 setNavigationMode()
的标签导航模式,例如后
设置页tabDemo = mTabsAdapter.addTab(bar.newTab()的setText(ABC),. Abc.class,空,ABC);bar.setNavigationMode(ActionBar.Navigation_mode_tabs);
这显示了在标签视图模式选项卡。我不知道,如果它的工作原理,但你可以尝试一下。
您也可以创建标签,而不是使用动作条选项卡的视图。我相信,你必须使用 ViewPager
或类似的东西。
I am using ActionBarSherlock to implement 4 tabs in an activity. The tabs display properly in portrait mode below the action bar and scrolling works as it should. When I switch to landscape mode, the tabs are placed in a spinner (they still function correctly). How can I force the tabs to display individually in landscape mode (either in the action bar or below)?
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ActionBar.Tab tab1 = getSupportActionBar().newTab();
tab1.setText("TAB 1 TEXT");
tab1.setTabListener(this);
getSupportActionBar().addTab(tab1);
ActionBar.Tab tab2 = getSupportActionBar().newTab();
tab2.setText("TAB 2 TEXT");
tab2.setTabListener(this);
getSupportActionBar().addTab(tab2);
ActionBar.Tab tab3 = getSupportActionBar().newTab();
tab3.setText("TAB 3 TEXT");
tab3.setTabListener(this);
getSupportActionBar().addTab(tab3);
ActionBar.Tab tab4 = getSupportActionBar().newTab();
tab4.setText("TAB 4 TEXT");
tab4.setTabListener(this);
getSupportActionBar().addTab(tab4);
解决方案
This is the default behavior for the ActionBar.
https://code.google.com/p/android/issues/detail?id=24439
I saw this
https://groups.google.com/forum/#!msg/android-developers/2unF5lKfn64/iKUX7JbbOo4J
After adding tabs to ActionBar call setNavigationMode()
for tab navigation mode, e.g.
Tab tabDemo=mTabsAdapter.addTab(bar.newTab().setText("ABC"),.Abc.class, null,"Abc");
bar.setNavigationMode(ActionBar.Navigation_mode_tabs);
It shows tabs in tabbed view mode. I don't know if it works but you can try it.
You can also create a view with tabs instead of using the ActionBar tabs. I believe you have to use ViewPager
or something like that.