首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在活动中实现CordovaWebView

如何在活动中实现CordovaWebView
EN

Stack Overflow用户
提问于 2012-11-14 00:29:56
回答 1查看 4.4K关注 0票数 2

我尝试在活动中实现CordovaWebView,但得到以下错误:

代码语言:javascript
复制
android.view.InflateException: Binary XML file line #12: Error inflating class
org.apache.cordova.CordovaWebView

以下是我的代码:

代码语言:javascript
复制
<?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>

和:

代码语言:javascript
复制
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,有人能告诉我为什么会这样吗?

提前感谢

科比

EN

回答 1

Stack Overflow用户

发布于 2013-02-08 11:32:32

尝试将此代码添加到您的主活动类中-

代码语言:javascript
复制
public Activity getActivity() {
      return this;
    }

参考:http://3z.uipc.org/blog_wp/mixing-phonegap-webview-with-native-ui/

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13364650

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档