如何在 Android 中创建自定义 webview? [英] How to create a custom webview in Android?

查看:42
本文介绍了如何在 Android 中创建自定义 webview?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有扩展 webview 的类 (MyCustomWebView) 我可以做这样的事情吗?

I have class (MyCustomWebView) that extend webview can i do something like this ?

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

如果没有,我可以做这样的事情.

if not, could i do something like this.

WebView webView = (WebView) findViewById(R.id.webview);
webView = new MyCustomWebView(this);

推荐答案

是的,您可以这样做:

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

然后在代码中你可以这样做:

Then in code you can do this:

MyCustomWebView myWebView = (MyCustomWebView) findViewById(R.id.myCustomWebView);

这篇关于如何在 Android 中创建自定义 webview?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆