如何从另一个类更新 WebView 的 loadUrl [英] How can I update the loadUrl of a WebView from another class

查看:44
本文介绍了如何从另一个类更新 WebView 的 loadUrl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在活动的主类中创建了一个 WebView,然后我有了一个新类,但是我无法修改在主类中创建的 webView 的任何属性,正确更新的步骤是什么?

I've create a WebView in the main class of an activity, then I've a new class but I can't modify any property of the webView created in the main class, what are the steps for the proper update?

谢谢.

推荐答案

在这种情况下,我可能会创建一个界面.然后在扩展 WebView 或诸如此类的类中,您可以从接口调用 loadUrl.然后,您可以从另一个类调用扩展 WebView 的类内部的接口方法.如果您需要示例,请告诉我,我可以提供.

In this situation i would probably create an interface. Then in the class that extends WebView or whatnot, you could call loadUrl from the interface. Then from another class you could call the interface method inside of the class that extends WebView. If you need an example let me know and i can provide one.

关于接口的更多信息:

有关接口的 Oracle 文档
有关如何实现接口的 Oracle 文档

这篇关于如何从另一个类更新 WebView 的 loadUrl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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