我尝试在活动中实现CordovaWebView,但得到以下错误:
android.view.InflateException: Binary XML file line #12: Error inflating class
org.apache.cordova.CordovaWebView以下是我的代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<!-- TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" /-->
<org.apache.cordova.CordovaWebView
android:id="@+id/tutorialView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>和:
public class NewActivity extends Activity implements CordovaInterface {
CordovaWebView cwv;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
cwv = (CordovaWebView) findViewById(R.id.tutorialView);
cwv.loadUrl("file:///android_asset/www/index.html");
}
}我的Phonegap版本是2.2.0,有人能告诉我为什么会这样吗?
提前感谢
科比
发布于 2013-02-08 11:32:32
尝试将此代码添加到您的主活动类中-
public Activity getActivity() {
return this;
}参考:http://3z.uipc.org/blog_wp/mixing-phonegap-webview-with-native-ui/
https://stackoverflow.com/questions/13364650
复制相似问题