Accessing android menu

Thread is closed for posting
4 posts, 0 answers
  1. Avi
    Avi avatar
    8 posts
    Member since:
    Jul 2013

    Posted 18 Mar 2015 Link to this post

    I tried to do something like this:
    var frame = frameModule.topmost();
         
        var activity = frame.android.activity;
     
        frame.android.showActionBar = true;
     
        activity.onPrepareOptionsMenu = function(menu) {
            var menuInflater = activity.getMenuInflater();
            inflater.inflate(getResource("R.menu.main"), menu);
        };
     
        activity.invalidateOptionsMenu();

    But onPrepareOptionsMenu doesn't get called.

    Is there a hook for this?
  2. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 19 Mar 2015 Link to this post

    Hi,

    You can't append the method like this.

    Anyway, I suppose that what you are trying to do is provide options menu for one of your pages. We are currently working on this feature, so you will not have to touch Android-specific stuff like you are trying to do. Here is an example of how one would be able to specify the options menu once we finish this feature:

    <Page loaded="pageLoaded">
      <Page.optionsMenu>
        <MenuItem text="{{ options[0].text }}" tap="optionTap"/>
        <MenuItem text="with icon" tap="optionTap" icon="~/app/test-icon.png"/>
      </Page.optionsMenu>
      <StackLayout>
        <Button text="button" />
      </StackLayout>
    </Page>

    Let us know if this is not what you are trying to achieve and explain the exact scenario that you are after.

    Regards,
    Rossen Hristov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. Avi
    Avi avatar
    8 posts
    Member since:
    Jul 2013

    Posted 19 Mar 2015 in reply to Rossen Hristov Link to this post

    Yes, that's pretty much what i'm trying to do.
  4. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 19 Mar 2015 Link to this post

    Hi,

    Cool. You will have this feature when we release the next version in April.

    Regards,
    Rossen Hristov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top