Skip to content Skip to sidebar Skip to footer

Menu With Action Bar Sherlock

I need an example or a tutorial on how to add menu items with action bar sherlock When I use the simple menu with the imports import android.view.Menu; import android.view.MenuInf

Solution 1:

You have to use Menu, MenuInflater and MenuItem classes from com.actionbarsherlock.view package:

import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem;

@OverridepublicbooleanonCreateOptionsMenu(Menu menu) {
    MenuInflaterinflater= getSupportMenuInflater();
    inflater.inflate(R.menu.settings_menu, menu);

    returnsuper.onCreateOptionsMenu(menu);
}

BTW, ActionBarSherlock contains a lot of samples.

Solution 2:

I used @StenaviN 's answer above but ran into problems with onContextItemSelected. This post solved it for me.

Basically, you just have to use

@OverridepublicbooleanonContextItemSelected(android.view.MenuItem item) {
    /* ... */
}

instead of

@OverridepublicbooleanonContextItemSelected(MenuItem item) {
    /* ... */
}

Solution 3:

I used @Matt's answer above but ran into problems with onContextItemSelected.

Basically, you just have to use

@OverridepublicbooleanonContextItemSelected(com.actionbarsherlock.view.MenuItem item) {
    /* ... */
}

instead of

@OverridepublicbooleanonContextItemSelected(android.view.MenuItem item) {
    /* ... */
}

Post a Comment for "Menu With Action Bar Sherlock"