onCreateOptionsMenu not showing up

794 views Asked by At

I have activity with three tabs which contain fragment each. I have created menu but its not showing up , My min sdk version is 14, I have tried on different devices but can't figure out the error. Code is:

@Override
        public boolean onCreateOptionsMenu(Menu menu) {
            MenuInflater inflater = getMenuInflater();
           inflater.inflate(R.menu.main, menu);
            return true;
        }


            @Override
            public boolean onOptionsItemSelected(MenuItem item) {
                    switch(item.getItemId()) {
                            case R.id.menuitem_search:
                                    Toast.makeText(getApplicationContext(), "search", Toast.LENGTH_SHORT).show();
                                    return true;
                          case R.id.menuitem_add:
                                    Toast.makeText(getApplicationContext(), "add", Toast.LENGTH_SHORT).show();
                                    return true;
                            case R.id.menuitem_share:
                                    Toast.makeText(getApplicationContext(), "share", Toast.LENGTH_SHORT).show();
                                    return true;
                            case R.id.menuitem_feedback:
                                    Toast.makeText(getApplicationContext(), "feedback", Toast.LENGTH_SHORT).show();
                                    return true;
                            case R.id.menuitem_about:
                                    Toast.makeText(getApplicationContext(), "about", Toast.LENGTH_SHORT).show();
                                    return true;
                            case R.id.menuitem_quit:
                                    Toast.makeText(getApplicationContext(), "quit", Toast.LENGTH_SHORT).show();
                                    return true;
                    }
                    return false;
            }

       @Override
        protected void onSaveInstanceState(Bundle outState) {
            super.onSaveInstanceState(outState);
            outState.putInt("tab", getActionBar().getSelectedNavigationIndex());
        }

XML is:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >

    <item
        android:id="@+id/menuitem_search"
        android:actionViewClass="android.widget.SearchView"
        android:icon="@android:drawable/ic_menu_search"
        android:showAsAction="ifRoom|collapseActionView"
        android:title="@string/menu_search">
    </item>
    <item
        android:id="@+id/menuitem_add"
        android:icon="@android:drawable/ic_menu_add"
        android:showAsAction="ifRoom"
        android:title="ADD">
    </item>
     <item
        android:id="@+id/menuitem_share"
        android:actionProviderClass="android.widget.ShareActionProvider"
        android:icon="@android:drawable/ic_menu_share"
        android:showAsAction="ifRoom"
        android:title="SHARE"
        >
    </item>
     <item
        android:id="@+id/menuitem_feedback"
        android:icon="@android:drawable/ic_menu_help"
        android:title="FEEDBACK"
        android:showAsAction="ifRoom">
    </item>
     <item
        android:id="@+id/menuitem_about"
        android:icon="@android:drawable/ic_menu_info_details"
        android:title="ABOUT">
    </item>
    <item
        android:id="@+id/menuitem_quit"
        android:icon="@android:drawable/ic_menu_close_clear_cancel"
        android:showAsAction="always"
        android:title="QUIT">
    </item>

</menu>

please help, Thanks in advance !!

0

There are 0 answers