我尝试在活动中实现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 任何人都能说出它为什么会发生?
提前致谢
KOBI
答案 0 :(得分:2)
尝试在主要活动类中添加它 -
public Activity getActivity() {
return this;
}
参考:http://3z.uipc.org/blog_wp/mixing-phonegap-webview-with-native-ui/