无法编辑输入字段中的文本获取错误:在非活动的inputconnection上的beginbatchedit

时间:2013-03-17 09:57:14

标签: android cordova jquery-mobile

我正在使用Android上的PhoneGap / Mobile jQuery制作应用程序。我正在使用phonegap版本2.3.0

我可以编辑表单中的某些字段,但是当我开始填写其他字段时,它不会显示字段内的文本。

我看到很多人都遇到了这个问题,但还没有人有解决方案

以下是人们遇到同样问题的一些链接

http://community.phonegap.com/nitobi/topics/phonegap_2_0_0_2_1_0_and_android_4_1_inputtext_text_not_taking_input_after_some_seconds http://community.phonegap.com/nitobi/topics/android_version_4_1_1

我没有太多使用android的经验,我正在使用带有phonegap的HTML5

我使用他们网络上的教程http://docs.phonegap.com/en/2.3.0/guide_getting-started_android_index.md.html#Getting%20Started%20with%20Android

来设置应用程序

它创建了我为应用程序phonetest命名的应用程序,我的主java文件包含此代码。

/*
       Licensed to the Apache Software Foundation (ASF) under one
       or more contributor license agreements.  See the NOTICE file
       distributed with this work for additional information
       regarding copyright ownership.  The ASF licenses this file
       to you under the Apache License, Version 2.0 (the
       "License"); you may not use this file except in compliance
       with the License.  You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

       Unless required by applicable law or agreed to in writing,
       software distributed under the License is distributed on an
       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
       KIND, either express or implied.  See the License for the
       specific language governing permissions and limitations
       under the License.
 */

package com.inam.phonetest;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.util.Log;

import org.apache.cordova.*;


    public class phonetest extends DroidGap
    {
        @Override
        public void onCreate(Bundle savedInstanceState)
        {
            // testing asdfsd
            try
            {
                    String pName = this.getClass().getPackage().getName();
                    Log.w("myApp", "no network"+"/data/data/"+pName+"/databases/");
                    this.copy("cps.db","/data/data/"+pName+"/databases/");
                    //this.copy("0000000000000001.db","/data/data/"+pName+"/databases/file__0/");
            }
            catch (IOException e)
            {

                e.printStackTrace();
            }

            File database=getApplicationContext().getDatabasePath("cps.db");

            if (!database.exists()) {
                // Database does not exist so copy it from assets here
                Log.w("Database", "Not Found");
            } else {
                Log.w("Database", "Found");
            }


            super.onCreate(savedInstanceState);
              ////////////
            setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
            super.loadUrl("file:///android_asset/www/index.html");
        }

        void copy(String file, String folder) throws IOException 
        {

         File CheckDirectory;
         CheckDirectory = new File(folder);
         if (!CheckDirectory.exists())
         { 
          CheckDirectory.mkdir();
         }

            InputStream in = getApplicationContext().getAssets().open(file);
            OutputStream out = new FileOutputStream(folder+file);

            // Transfer bytes from in to out
            byte[] buf = new byte[1024];
            int len; while ((len = in.read(buf)) > 0) out.write(buf, 0, len);
            in.close(); out.close();

        }
    }

我的HTML文件有这个脚本

<table><tr>
<td><input  name="last_name" id="last_name" type="text" class="mytextfield"  style="height:35px; width:250px;" tabindex=""  value="" /></td>
      <td  ><font color="red">*</font>Home Phone Number </td>
      <td  ><input  name="phone_num" id="phone_num"  value=""  tabindex="" type="text" pattern="[0-9]*" maxlength="10" /></td>
    </tr>
</table>

1 个答案:

答案 0 :(得分:0)

我在输入字段中使用maxlengthmax,并且该字段并没有限制我输入超过maxlength和max的字符,这会以某种方式违反任何规则并且它会停止显示之后的领域。