如何使用 Android 版 Phonegap 软键盘插件?
我正在使用 Phonegap 开发 Android 应用程序。我需要使软键盘以编程方式出现。我正在使用 SoftKeyboard 插件,可以在此处找到。谁能告诉我如何正确包含这个插件&让它发挥作用吗?我已尝试在 Phonegap Wiki,但该插件无法正常工作。
[更新] 我已将插件添加到路径
com/zenexity/SoftKeyBoardPlugin/SoftKeyBoard.java
更新了 plugins.xml
并包含
<plugin name="SoftKeyBoard" value="com.zenexity.SoftKeyBoardPlugin.SoftKeyBoard"/>
在中www
文件夹添加了 softkeyboard.js
,并在 index.html
中添加了以下内容,
plugins.SoftKeyBoard.show(function () {
// success
},function () {
// fail
});
但没有任何反应,键盘没有显示。
I am developing an Android application using Phonegap. I need to make the softkeyboard appear programatically. I am using the SoftKeyboard plugin which is found here. Can anyone tell me how to properly include this plugin & make it work? I have tried the tutorial found on the Phonegap Wiki, but the plugin is not working.
[Update] I have added the plugin to the path
com/zenexity/SoftKeyBoardPlugin/SoftKeyBoard.java
Updated plugins.xml
and included
<plugin name="SoftKeyBoard" value="com.zenexity.SoftKeyBoardPlugin.SoftKeyBoard"/>
Then in the www
folder added softkeyboard.js
, and the following in index.html
plugins.SoftKeyBoard.show(function () {
// success
},function () {
// fail
});
But nothing happens, the keyboard is not displaying..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这就是我让 SoftKeyBoard 在我的应用程序中工作的方式。
DroidGap Side
添加到 /res/xml/plugins.xml:
<代码><插件 name="SoftKeyBoard" value="com.phonegap.plugins.SoftKeyboard.SoftKeyBoard" />
/assets/www
Side在包含phonegap javascript 后添加到包含其他 javascript 的 header 中的 index.html:
<代码>< script type="text/javascript" charset="utf-8" src="js/softkeyboard.js">
如果您在设备上或使用类似的内容,则可以调用以下命令Ripple:
或者类似的东西,如果你想确保命名空间可用,这将防止未定义的问题:
我想你出错的地方可能是没有在你的index.html头中包含js/softkeyboard.js。
希望这对您有帮助
This is how I got SoftKeyBoard working in my application.
DroidGap Side
add to /res/xml/plugins.xml:
< plugin name="SoftKeyBoard" value="com.phonegap.plugins.SoftKeyboard.SoftKeyBoard" />
/assets/www
Sideadd to index.html in the head where your other javascripts are included after you have included the phonegap javascript:
< script type="text/javascript" charset="utf-8" src="js/softkeyboard.js"></script>
You can then call the following if you are on device or using something like Ripple:
or something like this if you want to make sure the namespace is available, which will prevent undefined problems:
I think maybe where you went wrong was not including the js/softkeyboard.js in your head of index.html.
Hope this helps you
对于最新版本的 PhoneGap (Apache Cordova 2.1.0),我必须执行以下操作:
安装这些反映项目名称更改的插件源:
https://github.com/originalgremlin/phonegap-plugins/tree/master/Android/SoftKeyboard< /a>
在包含 cordova.js 文件后,将其放入 HTML 文件中:
将其添加到 res/xml/config.xml 插件部分的底部:
现在,假设这个 HTML:
这个 jQuery 应该做一些有用的事情:
For the latest version of PhoneGap (Apache Cordova 2.1.0) I had to do the following:
Installed these plugin sources which reflected the project name change:
https://github.com/originalgremlin/phonegap-plugins/tree/master/Android/SoftKeyboard
Put this in your HTML file, after including the cordova.js file:
Add this to the bottom of the res/xml/config.xml plugins section:
Now, assuming this HTML:
This jQuery should do something useful:
尝试这样:
JS文件中的代码没有将其放在“plugins”命名空间中。
或者只是使用 PhoneGap 插件完整命名空间:
Try it like this:
The code in the JS file does not put it in the "plugins" namespace.
Orjust use the PhoneGap plugins full namespace:
Cordova 3.0 + JQM 1.3.2: 在 config.xml 中将“全屏”更改为“false”修复了“adjustPan”并防止在显示键盘时覆盖我的输入。然而,blur() 不会关闭键盘,这个插件运行得非常好。
对于最新版本的phonegap:
plugins .SoftKeyBoard.hide(function() {//成功 }, function() {//失败 });
Cordova 3.0 + JQM 1.3.2: Changing "fullscreen" to "false" in config.xml fixed the "adjustPan" and prevented my inputs from being covered when the keyboard displayed. However, blur() would not close the keyboard and this plugin worked wonderfully.
For the almost latest version of phonegap:
<feature name="SoftKeyBoard"><param name="android-package" value="com.yourAppPackage" /></feature>
plugins.SoftKeyBoard.hide(function() {//success }, function() {//fail });
通过链接。这是完整的项目:--
SoftKeyboardPlugin by Simon McDonald
go through the link. here is the full project:--
SoftKeyboardPlugin by Simon McDonald