Android Question Menus between activities

Discussion in 'Android Questions' started by Alberto Michelis, Jun 4, 2015.

  1. Alberto Michelis

    Alberto Michelis Active Member Licensed User

    Hi,
    Any way of having a menu definition in one module and use it in all the activities of the app?

    And where can I found the icon of this menu?
    Are they an android resource I can use? see image.

    Thanks
     

    Attached Files:

    Last edited: Jun 4, 2015
  2. DonManfred

    DonManfred Expert Licensed User

  3. Erel

    Erel Administrator Staff Member Licensed User

    You can use a class to add the menu items (pass the activity as a parameter to the class). The menu click event will still fire on the activity module. You can use a single event for all the menu items and then delegate it to the class. This will allow you to share the code between all the modules:
    Code:
    Sub Menu_Click
     MenuHandlerClassInstance.MenuClick(
    Sender'sender will be the menu text
    End Sub
     
    Peter Simpson likes this.
  4. Alberto Michelis

    Alberto Michelis Active Member Licensed User

    It is this or I need to add the menu, items and click code in all the activities?
    Thats what you normally do?
    May exists a compiler INCLUDE(file) to include the same code in many modules?
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    You can add the menus from the class code. This is why you need to pass the activity object to the class.

    You only need to have one event sub in the activity that will delegate the event to the class instance.
     
Loading...