krasnoff
krasnoff

Reputation: 967

How to implement CordovaWebView in an activity

I try to implement CordovaWebView in an activity but I get the following Error:

android.view.InflateException: Binary XML file line #12: Error inflating class
org.apache.cordova.CordovaWebView

Here is my Code:

<?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>

and:

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");
}
}

My Phonegap version is 2.2.0 can anyone tell why it is happening?

thanks in advance

kobi

Upvotes: 2

Views: 4438

Answers (1)

zainoz.zaini
zainoz.zaini

Reputation: 938

try add this in your main activity class-

public Activity getActivity() {
      return this;
    }

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

Upvotes: 2

Related Questions