• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Can you change menu order based on user action?

You don't need to inflate XML to generate the menu, you can do it in code. You should be fine to check preferences in that code.


Example of creating menu without inflating xml
Code:
    static final int MENU_ADD_WIDGET = 1;
    static final int MENU_CLEAR_ALL = 2;
    static final int MENU_QUIT = 3;

    public boolean onCreateOptionsMenu(Menu  menu) {
        menu.add(0, MENU_ADD_WIDGET, 0, "Add Widget");
        menu.add(1, MENU_CLEAR_ALL, 0, "Clear all");
        menu.add(2, MENU_QUIT, 0, "Quit");
        return true;
    }
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones