Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7789199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:13:34+00:00 2026-06-01T21:13:34+00:00

My application have something like this: TabActivity Tab 1 (ActivityGroup) Activity > Activity >

  • 0

My application have something like this:

TabActivity
    Tab 1 (ActivityGroup)
        Activity > Activity > MapActivity
    Tab 2 (ActivityGroup)
        MapActivity

The problem is that in the Tab 2 MapActivity the options menu does not appear, even displays an error. But in the first MapActivity works perfectly. I put a breakpoint inside the method onCreateOptionsMenu but even entered it.

I used this tutorial for make my application based in TabHost.

Could anyone help me to know why in one works and the other not?

Thanks in advance.

UPDATE

About version:

<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="13" />

First MapActivity class:

public boolean onCreateOptionsMenu(Menu menu) {
    menu.add(0, 0, 1, "Nearest");
    menu.add(0, 1, 1, "Directions");
    return true;
}

Second MapActivity class:

public boolean onCreateOptionsMenu(Menu menu) {
    menu.add(0, 0, 1, "Nearest");
    menu.add(0, 1, 1, "Region");
    return true;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T21:13:36+00:00Added an answer on June 1, 2026 at 9:13 pm

    Basically a TabHost only has one options menu.

    I haven’t tested it, but my guess would be that it’s just using the first activity that returns true from onCreateOptionsMenu. If you want a different options menu for each tab, you’ll have to do several things:

    1) Subclass TabHost and override onCreateOptionsMenu and onPrepareOptionsMenu.

    2) When the tab changes (can’t remember how you listen for this event, google it), call invalidateOptionsMenu, which will force a call to onPrepareOptionsMenu.

    3) In onPrepareOptionsMenu, remember to call menu.clear(), and then do the normal menu inflation stuff that you do in onCreateOptionsMenu to create your tab specific options menu.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Visual Studio 2008 C++ application that does something like this: template<
This is a C# console application. I have a function that does something like
I have something like this in my Spring Application: public class Book{ public Book(){
I have WPF application and a window in it. Lets have something like this
I have something like this in application.html.haml: #header = image_tag(header.jpg) How do I make
In my web/MySQL application I have something like this to get distance between two
Let's say I have something like this in my application layout: <title> <%= @page_title
I have an application that is a Tab activity with various tabs that load
I have something like this in my Silverlight application: <navigation:Page x:Class=PPCa.Modules.ProjectManager.Client.Views.ProjectDetailView xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:d=http://schemas.microsoft.com/expression/blend/2008
I have something like this in my AJAX application: <html> <head> <script type=text/javascript> var

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.