简体   繁体   English

带有操作栏的导航选项卡用于我的设置

[英]Navigation Tabs with Action Bar for my settings

i'm kinda new to Android but, i'm creating an app that will use Tabs for navigation and i'm using ActionBarSherlock as a library to use FragmentsTabs. 我是Android的新手,但是我正在创建一个将使用Tabs进行导航的应用程序,并且将ActionBarSherlock用作使用FragmentsTabs的库。 I create my tabs succesfully :) ! 我成功创建了选项卡:)! Here's how i did it: 这是我的做法:

public class Main extends SherlockFragmentActivity {


protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    ActionBar bar = getSupportActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    ActionBar.Tab tab1 = bar.newTab();
    ActionBar.Tab tab2 = bar.newTab();
    tab1.setText("HOW IT WORKS");
    tab2.setText("CURRENT POSITION");
    tab1.setTabListener(new MyTabListener());
    tab2.setTabListener(new MyTabListener());
    bar.addTab(tab1);
    bar.addTab(tab2);

}

And then i have my TabListener who handles the content replacements between tabs, that's working fine. 然后我有我的TabListener来处理选项卡之间的内容替换,这很好。 But my QUESTION IS how can i add an OptionsMenu now that i have the tabs?? 但是我的问题是,现在我有了选项卡,如何添加选项菜单? i understand that i'm adding the Tabs to the Action Bar, but i need to add an OptionMenu to the Settings of my app. 我知道我正在将选项卡添加到操作栏,但是我需要在我的应用程序的设置中添加一个OptionMenu。 So it would be something like this next example: 因此,将类似于以下示例:

Image of a Tab Navigation with OptionMenu at the top 标签导航的图像,顶部带有OptionMenu

As you can see, there's the tabs navigation but at the top you'll see the logo and the OptionsMenu, and i don't know how to do that with the Tabs already implemented, i tried to do it as the usual implementation of a OptionsMenu and add the public boolean onCreateOptionsMenu(Menu menu) inside my Activity and there inflate my menu, but i'm recieving this errors: 如您所见,有选项卡导航,但是在顶部您会看到徽标和OptionsMenu,而且我不知道如何在已实现的选项卡中执行此操作,我试图像通常那样实现OptionsMenu并在我的Activity中添加public boolean onCreateOptionsMenu(Menu menu)然后在我的菜单中充气,但是我收到此错误:

- Cannot override the final method from SherlockFragmentActivity
- overrides 
 com.actionbarsherlock.app.SherlockFragmentActivity.onCreateOptionsMenu

Here's an ScreenShot of how it looks the app so you can understand me. 这是有关应用程序外观的屏幕截图,您可以了解我。

MyApp with tabs but i need to place the optionsMenu 带标签的MyApp,但我需要放置optionsMenu

The override error is probably because your import is for the standard Android Menu, and not the ABS one. 覆盖错误可能是因为您导入的是标准Android菜单,而不是ABS。

Check your imports to make sure your onCreateOptionsMenu(Menu menu) is based on com.actionbarsherlock.view.Menu (and NOT android.view.MenuItem ). 检查您的导入,以确保您的onCreateOptionsMenu(Menu menu)基于com.actionbarsherlock.view.Menucom.actionbarsherlock.view.Menu android.view.MenuItem )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM