Skip to content Skip to sidebar Skip to footer

Actionbarsherlock Forceoverflow Resource Not Found

I upgraded to version 4.2 and found that my old code did not compile because it appears the ForceOverflow parent theme has been removed. After Googling this issue it appears that

Solution 1:

Instead of trying to get a "real" overflow menu, we can fake it with a SubMenu.

It will look like and behave like the original overflow button, just better because it will always be there.

private Menu mainMenu;
private SubMenu subMenu1;

    @OverridepublicbooleanonCreateOptionsMenu(Menu menu) {

    mainMenu = menu;

    subMenu1 = menu.addSubMenu("");
    subMenu1.add("Settings");
    subMenu1.add("About");
    subMenu1.add("Help");

    MenuItemsubMenu1Item= subMenu1.getItem();
    subMenu1Item.setIcon(R.drawable.ic_menu_moreoverflow_normal_holo_dark);
    subMenu1Item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

    returnsuper.onCreateOptionsMenu(menu);
}

Of course you can set the subMenus just as you did before. With groudID, itemID etc.

Note that I already choosed *ic_menu_moreoverflow_normal_holo_dark* as the menu icon. This way the button will also look like an overflow.

Now we just need this Submenu to open when the user pressed the hardware menu button. We can do this very easy if you set mainMenu and subMenu1 like i did before.

@OverridepublicbooleanonKeyUp(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_MENU) {
            mainMenu.performIdentifierAction(subMenu1.getItem().getItemId(), 0);
            returntrue;
    }
    returnsuper.onKeyUp(keyCode, event);
}

Beware that you import:

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

and not:

import android.view.MenuItem;

Post a Comment for "Actionbarsherlock Forceoverflow Resource Not Found"