如何使用PhoneGap的SoftKeyboard插件为Android? [英] How to use Phonegap SoftKeyboard Plugin for Android?

查看:167
本文介绍了如何使用PhoneGap的SoftKeyboard插件为Android?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发使用的PhoneGap 的Andr​​oid应用程序。我需要做的softkeyboard出现编程。我现在用的是SoftKeyboard插件,它被发现这里。谁能告诉我如何正确包含此插件及功放;使它发挥作用?我曾尝试在<一个找到的教程href="http://wiki.phonegap.com/w/page/43708611/How%20to%20Install%20a%20PhoneGap%20Plugin%20for%20Android">Phonegap维基的,但该插件是行不通的。

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

更新 plugins.xml ,其中包括

<plugin name="SoftKeyBoard" value="com.zenexity.SoftKeyBoardPlugin.SoftKeyBoard"/>

然后在加入 softkeyboard.js ,而在以下指数 WWW 文件夹html的

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..

推荐答案

这就是我得到了SoftKeyBoard在我的应用程序中工作。

This is how I got SoftKeyBoard working in my application.

DroidGap侧

  • 创建/ src目录/ COM / PhoneGap的/插件/ SoftKeyboard里面提供的文件SoftKeyBoard.java
  • 添加到/res/xml/plugins.xml:

  • create /src/com/phonegap/plugins/SoftKeyboard with provided file SoftKeyBoard.java inside
  • add to /res/xml/plugins.xml:

&LT;插件名称=SoftKeyBoard值=com.phonegap.plugins.SoftKeyboard.SoftKeyBoard/&GT;

/资产/ WWW

/assets/www Side

  • 提供的文件softkeyboard.js添加/资产/ WWW / JS
  • 添加在头部的index.html,你的其他的JavaScript包含已包含了PhoneGap的的JavaScript后:

  • add provided file softkeyboard.js to /assets/www/js
  • add to index.html in the head where your other javascripts are included after you have included the phonegap javascript:

&LT;脚本类型=文/ JavaScript的字符集=utf-8SRC =JS / softkeyboard.js&GT;&LT; / SCRIPT&GT;

您可以调用,如果你是在设备或以下使用类似纹波:

You can then call the following if you are on device or using something like Ripple:

window.plugins.SoftKeyBoard.show(function () {
  // success
},function () {
  // fail
});

或者这样的事情,如果你想确保空间可用,这将prevent不确定的问题:

or something like this if you want to make sure the namespace is available, which will prevent undefined problems:

((((window || {}).plugins || {}).SoftKeyBoard || {}).show || function(){})();

我想,也许你​​在哪里错了是不包括在你的index.html的头JS / softkeyboard.js。

I think maybe where you went wrong was not including the js/softkeyboard.js in your head of index.html.

希望这有助于你

这篇关于如何使用PhoneGap的SoftKeyboard插件为Android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆