Android options menu on a tabbed Group activity not working
<p>i have created various tabs where each tab has a group activity so that a user can browse through various different activities in the same tab.</p>

<p>When i add  options menu, it simply doesnt appear at all but apears fine if it is a regualr activity shown on its own and not inside a grouped activity thats in a tab.</p>

<p>Here is what the activity looks like that cant display the options menu:</p>

<pre><code>public class CardsActivity extends Activity implements OnItemSelectedListener {

private static final int OPTIONS_CHANGE_CARD_COLOUR = 0;
    private static final int OPTIONS_CHANGE_CARD_NICKNAME = 1;
    private static final int OPTIONS_DELETE_CARD = 2;


@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.cards);
        intializeView();
        setCorrectViewForSelectedCard(0);

    }

@Override
    public boolean onCreateOptionsMenu(Menu menu) {

        VisaTabGroupActivity parentActivity = (VisaTabGroupActivity)getParent();


        boolean result = parentActivity.onCreateOptionsMenu(menu);

        menu.add(0, OPTIONS_CHANGE_CARD_COLOUR, Menu.NONE, getApplication().getString(R.string.label_change_colour));
        menu.add(0, OPTIONS_CHANGE_CARD_NICKNAME, Menu.NONE, getApplication().getString(R.string.label_edit_nickname));
        menu.add(0, OPTIONS_DELETE_CARD, Menu.NONE, getApplication().getString(R.string.label_delete_card));

        return result;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case OPTIONS_CHANGE_CARD_COLOUR:
            showDialog(DialogFactory.CHANGE_COLOUR);
            break;
        case OPTIONS_CHANGE_CARD_NICKNAME:
            break;
        case OPTIONS_DELETE_CARD:
            showDialog(DialogFactory.DELETE_CARD);
            break;
        }
        return true;
    }


}
</code></pre>

<p>Here is the tab group  activity class:</p>

<pre><code>/**
 * &lt; Manage activities in a tab so that when switching to a new activity from within a tab, it wont remove the Tabs at
 * the top but instead replace the tabbed activity screen only.
 * &lt;p&gt;
 * &lt;hr&gt;Initialising the first activity that will &lt;/h1&gt;
 * To use this ActivityGroup, simply extend this class and override the onCreate and call
 * {@code protected void onCreate(Bundle savedInstanceState)} To set the first intial activity that this
 * ActivityTabgroup will display first.
 * &lt;p&gt;
 * &lt;hr&gt;&lt;/h1&gt;
 *  &lt;p&gt;
 * 
 * @author 
 */
public class TabGroupActivity extends ActivityGroup {

    /** An array list that stores the activities ID values */
    private ArrayList&lt;String&gt; mChildActivityIdList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        if (mChildActivityIdList == null)
            mChildActivityIdList = new ArrayList&lt;String&gt;();
    }

    /**
     * Used to override the on key press of the back button so we can call finish() on the child Activity itself and not
     * the whole ActivtyGroup
     */
    @Override
    public boolean onKeyUp(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            onBackPressed();
            return true;
        }
        return super.onKeyUp(keyCode, event);
    }

    /**
     * Starts a child activity from within a tab group
     * 
     * @param id the Unique identifier for this activity
     * @param intent The intent object used to start the activity
     */
    public void startTabChildActivity(String id, Intent intent) {
        Window window = getLocalActivityManager().startActivity(id, intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
        if (window != null) {
            mChildActivityIdList.add(id);
            setContentView(window.getDecorView());
        }
    }

    /**
     * This is called when the current activity calls the finish() and tries to set the previous activity that was
     * displayed before
     */
    @Override
    public void finishFromChild(Activity child) {
        LocalActivityManager manager = getLocalActivityManager();
        int index = mChildActivityIdList.size() - 1;

        // if this is the first activity that was displayed in the tab group(i.e. no previous viewed activity in this
        // group) call finish on the entire group activity.
        if (index &lt; 1) {
            finish();

        } else {
            // remove current activity
            manager.destroyActivity(mChildActivityIdList.get(index), true);
            mChildActivityIdList.remove(index);

            // set previous activity by getting the id and the intent from the LocalActivityManager and then set the
            // view for this activity.
            index--;
            String lastId = mChildActivityIdList.get(index);
            Intent lastIntent = manager.getActivity(lastId).getIntent();
            Window newWindow = manager.startActivity(lastId, lastIntent);
            setContentView(newWindow.getDecorView());
        }

    }

    /**
     * When the back key is pressed. call finish on the current child activity.
     */
    @Override
    public void onBackPressed() {
        int length = mChildActivityIdList.size();
        if (length &gt; 1) {
            Activity current = getLocalActivityManager().getActivity(mChildActivityIdList.get(length - 1));
            current.finish();
        } else {
            // go back to the dashboard view or the previous view before that
            this.finish();
        }
    }

}
</code></pre>

<p>Below is the group ctivty that extends the above groupactivity defined above:</p>

<pre><code>/**
 * Tab group activity that extends Tabgroup. This is the starting point of the grouped activity tabs. specify the
 * first activity taht shoudl be displayed in this Group Activity
 * 
 * 
 */
public class CardsTabGroupActivity extends TabGroupActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        //startTabChildActivity(AddFirstCardActivity.class.getName(), new Intent(this, AddFirstCardActivity.class));
        startTabChildActivity(CardsActivity.class.getName(), new Intent(this, CardsActivity.class));


    }

}

And finally the Tab activity



    public class TabActivity extends TabActivity implements IntentFilterConstants{

        private static final String TAG = "TabActivity";
        private TabHost mTabHost;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.tabs_layout);   
            intialiseTabs();
        }

        private void intialiseTabs() {
            mTabHost = getTabHost();
            final String cards = getString(R.string.cards);
            final String inbox = getString(R.string.inbox);
            final String settings = getString(R.string.settings);

            final String[] tabNames = new String[] { cards, inbox, settings };
            final int[] tabIcons = new int[] { R.drawable.tab_cards_icon, R.drawable.tab_inbox_icon,
                    R.drawable.tab_settings_icon };
            // TODO: check to see if the user has added there first card to the system. if not, when the user clicks the
            // card tab, the application will launch the AddFirstCardActivity instead. Do we need to store at a bare
            // minimum, the cards reference in the application so we know if the user has added one successfully?

            final String[] activityClasses = new String[] { CardsTabGroupActivity.class.getCanonicalName(),
                    InboxActivity.class.getCanonicalName(), SettingsActivity.class.getCanonicalName() };
            final int totalTabs = tabNames.length;

            for (int i = 0; i &lt; totalTabs; i++) {
                addTab(tabNames[i], activityClasses[i], tabIcons[i]);
            }

            mTabHost.setCurrentTab(getIntent().getIntExtra(INTENT_EXTRA_TAB, 0));
        }

        /**
         * Creates the activity intent and puts it into the tab host.
         * 
         * @param tabName Tab name to display.
         * @param className Class to load in the tab.
         * @param icon Tab icon to display.
         */
        @SuppressWarnings("rawtypes")
        private void addTab(final String tabName, String className, int icon) {
            try {
                Class activity = getClassLoader().loadClass(className);
                Intent activityIntent = new Intent(this, activity);


                TabHost.TabSpec spec = mTabHost.newTabSpec(tabName);
                spec.setIndicator(getTabView(tabName, icon));
                spec.setContent(activityIntent);
                mTabHost.addTab(spec);

            } catch (ClassNotFoundException e) {
                Log.e(TAG, "Could no load class " + className);
                e.printStackTrace();
            }
        }

        /**
         * Gets the tab view.
         * 
         * @param text Tab name text.
         * @param icon Tab icon.
         * @return Tab item view.
         */
        protected View getTabView(String text, int icon) {
            View parent = View.inflate(this, R.layout.visa_tab_item, null);
            TextView view = (TextView)parent.findViewById(R.id.tab_item_text);
            view.setCompoundDrawablesWithIntrinsicBounds(0, icon, 0, 0);
            parent.setBackgroundResource(R.drawable.tab_selector);
            view.setText(text);
            return parent;
        }
    }
</code></pre>
