PhoneGap的Andr​​oid版不接受9键 [英] PhoneGap for Android does not accept the 9 key

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

问题描述

我有一个奇怪的问题,在我的PhoneGap为基础的Andr​​oid应用程序。在某些屏幕, 数字9键被完全忽略。这发生在我所有的Andr​​oid 2.X设备。我曾试图与PG的previous版本,发现 这个问题第一次发生在1.2版。

下面是code到应该重现问题的样本index.html文件。在这两个Android 2.2及2.3,文本框标记为破不接受数9作为输入。

 <!DOCTYPE HTML>
    < HTML>
    < HEAD>
        <冠军>测试< /标题>
        <风格>
        体
        {
            保证金:0;
            填充:0;
            字体大小:20像素;
        }

        输入
        {
            高度:20像素;
        }

        #container_second
        {
            溢出:隐藏;
            位置:亲属;
            宽度:100%;
            高度:150像素;
        }

        #container_second DIV
        {
            左:-2000px;
            位置:绝对的;
            -webkit变换:矩阵(1,0,0,1,2000,0);
        }
        < /风格>
    < /头>
    <身体GT;
        < BR />
        < D​​IV ID =container_first>
            < D​​IV>
                工作案:其中; BR /><输入类型=文本/>< BR />< BR />
                工作电话:< BR /><输入类型=电话/>
            < / DIV>
        < / DIV>

        < BR />< BR />

        < D​​IV ID =container_second>
            < D​​IV>
                残破的文字:LT; BR /><输入类型=文本/>< BR />< BR />
                残破的电话:< BR /><输入类型=电话/>
            < / DIV>
        < / DIV>
    < /身体GT;
    < / HTML>
 

解决方案

这可能与的这个问题。出于某种原因,PhoneGap的呼吁setNavDump在Web视图的WebSettings。 setNavDump是根据<一个过时的方法href="http://developer.android.com/reference/android/webkit/WebSettings.html#setNavDump%28boolean%29"相对=nofollow> Android的文档所以你应该,如果你禁用就可以了。

一种方式来做到这一点是通过覆盖在类中init方法扩展DroidGap

  @覆盖
公共无效的init(){
    super.init();
    this.appView.getSettings()setNavDump(假)。
}
 


如果还是不行,请尝试在现有的的onCreate 方法使用loadURL 通话后其添加:

  @覆盖
公共无效的onCreate(包savedInstanceState){
    // ...喀嚓...
    super.loadUrl(文件:///android_asset/www/index.html,12000);
    this.appView.getSettings()setNavDump(假)。
    // ...喀嚓...
}
 

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

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

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