简体   繁体   中英

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. 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. 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. So it would be something like this next example:

Image of a Tab Navigation with OptionMenu at the top

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:

- 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

The override error is probably because your import is for the standard Android Menu, and not the ABS one.

Check your imports to make sure your onCreateOptionsMenu(Menu menu) is based on com.actionbarsherlock.view.Menu (and NOT android.view.MenuItem ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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