3

I have a weird problem. I recently developed an App for ios using Phonegap and Xcode. It went well, they are in the App store, everything worked. One of the elements is a simple email form, written in HTML. It looks like this:

<form name="emailformbtn" id="emailformbtn" onsubmit="submitHandler(e);" action="#emailfromBtn">
                    To: <input type="email" name="emailvarto"/>
                    Message:<textarea cols="40" rows="8" id="emailmessagebtn" name="emailmessage">Email Message</textarea>
                    <input type="button" value="send" onsubmit="submitHandler(e);" onclick="emailProcessfromBtn();"/>
                </form>

Works in ios using Phonegap and Jquery mobile. So i decided to convert the app into Android. Converting all the ObjectiveC into Java, and the rest should work because they are both Phonegap/Cordova.

I am Using Cordova 2.0 and Android 4.1

A lot of it does, but when I try to touch the input of the emails field, it does nothing, and Eclipse displays the message:

The View is not attached to a window. 

Its a Phonegap/Cordova element. I'm not even sure what its trying to say. Is there an issue with Android and Jquery mobile, or does touching input fields in Android using phonegap not invoke native Keyboards?

Any direction or advice on this problem would be greatly appreciated.

Just to make things clearer, even though I followed Phonegap's configuration guide tot he letter, Here is the contents of the Activity.java file:

package uk.co.testdevelopment.testapp.droidapp;

import android.os.Bundle;
import android.view.Menu;
import org.apache.cordova.*;

public class MainActivity extends DroidGap {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    super.loadUrl("file:///android_asset/www/index.html");
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}
}
4

2 回答 2

1

你确定你的活动正在扩展'DroidGap'而不是'Activity'?这绝对听起来很奇怪,看起来更像是科尔多瓦配置的问题,而不是与您的 html 相关的任何问题

于 2012-09-11T14:26:59.530 回答
0

问题似乎出在您指定调用 inflate 的菜单上。对于 ICS 及更高版本,菜单是在应用程序首次运行时创建的,而不是在访问菜单时创建的。我建议删除您的菜单代码以消除查看错误。

顺便说一句:视图必须附加到 Android 视图的根元素,这通常由 DroidGap 处理。DroidGap 也有菜单处理程序,您可能想看看使用菜单插件或使用 CordovaWebView 方法来开发适用于 Android 4.x 的混合应用程序。

于 2012-09-11T20:58:45.897 回答