简体   繁体   English

带有PhoneGap的原生Android菜单项中的jQuery Mobile changePage

[英]jQuery Mobile changePage from native Android menu item with PhoneGap

I've created a web app using jQuery Mobile. 我已经使用jQuery Mobile创建了一个Web应用程序。 Works great. 效果很好。 I've even managed to build a working APK using PhoneGap. 我什至设法使用PhoneGap构建了可运行的APK。

One thing I am having trouble with: 我遇到的一件事:

How do I perform a $.mobile.changePage() on the click event of a native menu item?Specifically, I press the menu button on the device, it shows me the option I created, how do I link the click of that option to a changePage() in jQM? 我如何在本机菜单项的click事件上执行$.mobile.changePage() ?具体来说,我按下设备上的菜单按钮,它向我显示了我创建的选项,如何链接该选项的点击到jQM中的changePage()

I've created the menu item in the xml file in Eclipse and, in my searching, I've found Java code associated with onOptionsItemSelected(), which I think is close to what I am looking for, but I have zero experience with Java. 我已经在Eclipse的xml文件中创建了菜单项,并且在搜索中发现了与onOptionsItemSelected()相关联的Java代码,我认为它与我要寻找的内容很接近,但是我对Java的使用经验为零。 I can't even install Minecraft mods properly. 我什至无法正确安装Minecraft mod。 I guess I am basically wondering how to execute Javascript in the onclick of a native menu item. 我想我基本上想知道如何在本机菜单项的onclick中执行Javascript。

document.addEventListener("menubutton", yourCallbackFunction, false);

You'll need to ensure that you've included cordova.js in your code in order to use this event 您需要确保已在代码中包含cordova.js才能使用此事件

See http://docs.phonegap.com/en/2.0.0/cordova_events_events.md.html#Events 参见http://docs.phonegap.com/en/2.0.0/cordova_events_events.md.html#Events

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM