How to create a custom webview in Android?

I have a class (MyCustomWebView) that extends webview, can I do something like this?

<MyCustomWebView 
    android:id="@+id/myCustomWebView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
/>

If not, can I do something like this.

WebView webView = (WebView) findViewById(R.id.webview);
webView = new MyCustomWebView(this);
+5
source share
1 answer

Yes you can do this:

    <your.package.MyCustomWebView android:id="@+id/myCustomWebView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    />

Then in the code you can do this:

MyCustomWebView myWebView = (MyCustomWebView) findViewById(R.id.myCustomWebView);
+15
source

All Articles