适用于 Android 的 PhoneGap 不接受 9 键 [英] PhoneGap for Android does not accept the 9 key

查看:31
本文介绍了适用于 Android 的 PhoneGap 不接受 9 键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的基于 PhoneGap 的安卓应用有一个奇怪的问题.在某些屏幕上,数字 9 键被完全忽略.这发生在我所有的 Android 上2.X 设备.我尝试过以前版本的 PG,发现该问题首先出现在 v1.2 中.

这是应该重现问题的示例 index.html 文件的代码.在 Android 2.2 和 2.3 上,标记为损坏"的文本框不接受数字 9 作为输入.

 <头><title>测试</title><风格>身体{保证金:0;填充:0;字体大小:20px;}输入{高度:20px;}#container_second{溢出:隐藏;位置:相对;宽度:100%;高度:150px;}#container_second div{左:-2000px;位置:绝对;-webkit-transform: 矩阵(1, 0, 0, 1, 2000, 0);}</风格><身体><br/><div id="container_first"><div>工作文本:<br/><input type="text"/><br/><br/>工作电话:<br/><input type="tel"/>

<br/><br/><div id="container_second"><div>损坏的文本:<br/><input type="text"/><br/><br/>断开的电话:<br/><input type="tel"/>

解决方案

可能与这个问题.出于某种原因,PhoneGap 在 web 视图的 WebSettings 上调用 setNavDump.根据 android 文档 所以如果你禁用它应该没问题.

一种方法是覆盖扩展 DroidGap 的类中的 init 方法

 @Override公共无效初始化(){超.init();this.appView.getSettings().setNavDump(false);}

<小时>

如果这不起作用,请尝试在现有 onCreate 方法中的 loadUrl 调用之后添加它:

@Overridepublic void onCreate(Bundle savedInstanceState) {//... 剪...super.loadUrl("file:///android_asset/www/index.html", 12000);this.appView.getSettings().setNavDump(false);//... 剪...}

I have a strange problem in my PhoneGap-based android app. On certain screens, the number 9 key is completely ignored. This happens on all my Android 2.X devices. I have tried with previous versions of PG and found that the problem first occurred in v1.2.

Here is the code to a sample index.html file that should reproduce the issue. On both Android 2.2 and 2.3, the text boxes labeled as "broken" do not accept the number 9 as input.

    <!DOCTYPE html>
    <html>
    <head>
        <title>Test</title>
        <style>
        body
        {
            margin:0;
            padding:0;
            font-size:20px;
        }

        input
        {
            height:20px;
        }

        #container_second
        {
            overflow:hidden;
            position:relative;
            width:100%;
            height:150px;
        }

        #container_second div
        {
            left: -2000px;
            position: absolute;
            -webkit-transform: matrix(1, 0, 0, 1, 2000, 0);
        }
        </style>
    </head>
    <body>
        <br />
        <div id="container_first">
            <div>
                Working Text: <br /><input type="text" /><br /><br />
                Working Tel: <br /><input type="tel" />
            </div>
        </div>

        <br /><br />

        <div id="container_second">
            <div>
                Broken Text: <br /><input type="text" /><br /><br />
                Broken Tel: <br /><input type="tel" />
            </div>
        </div>
    </body>
    </html>

解决方案

It might be related to this issue. For some reason PhoneGap is calling setNavDump on the web view's WebSettings. setNavDump is an obsolete method according to the android docs so you should be fine if you disable it.

One way to do it is by overriding the init method in your class that extends DroidGap

    @Override
public void init() {
    super.init();       
    this.appView.getSettings().setNavDump(false);
}


If that doesn't work, try adding it after the loadUrl call in the existing onCreate method:

@Override
public void onCreate(Bundle savedInstanceState) {
    //... snip ...
    super.loadUrl("file:///android_asset/www/index.html", 12000);
    this.appView.getSettings().setNavDump(false);
    //... snip ...
}

这篇关于适用于 Android 的 PhoneGap 不接受 9 键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
移动开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆