1. Download our Official Android App: Forums for Android!

Apps Can you change menu order based on user action?

Discussion in 'Android Development' started by nirVrana, May 21, 2010.

  1. nirVrana

    nirVrana Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    1
    Joined:
    May 18, 2010

    May 18, 2010
    1
    0
    5
    Is it possible to change the order of the menu items based on the user choosing a particular preference?

    Is it possible for the user to re-order menu items so their most used options appear as icons when the menu button is pushed?
     

    Advertisement

  2. gorn

    gorn Member
    Rank:
    None
    Points:
    18
    Posts:
    48
    Joined:
    Mar 22, 2010

    Mar 22, 2010
    48
    11
    18
    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 (Text):
    1.  
    2.     static final int MENU_ADD_WIDGET = 1;
    3.     static final int MENU_CLEAR_ALL = 2;
    4.     static final int MENU_QUIT = 3;
    5.  
    6.     public boolean onCreateOptionsMenu(Menu  menu) {
    7.         menu.add(0, MENU_ADD_WIDGET, 0, "Add Widget");
    8.         menu.add(1, MENU_CLEAR_ALL, 0, "Clear all");
    9.         menu.add(2, MENU_QUIT, 0, "Quit");
    10.         return true;
    11.     }
    12.  
     

Share This Page

Loading...