This is a migrated thread and some comments may be shown as answers.

Accessing android menu

3 Answers 57 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Avi
Top achievements
Rank 1
Avi asked on 18 Mar 2015, 09:43 AM
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?

3 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 19 Mar 2015, 09:32 AM
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.

 
0
Avi
Top achievements
Rank 1
answered on 19 Mar 2015, 09:37 AM
Yes, that's pretty much what i'm trying to do.
0
Rossen Hristov
Telerik team
answered on 19 Mar 2015, 09:44 AM
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.

 
Tags
General Discussions
Asked by
Avi
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Avi
Top achievements
Rank 1
Share this question
or