首页 > 解决方案 > 使用 viewmodel 加载 Webview

问题描述

我之前使用 extends Activity 和 onCreate() 来加载在 xml 布局中定义的任何 webview。例如

public void onCreate(){
WebView webview = findViewById(R.id.my_webview);
webview.loadUrl("url");
---

但是现在,我们必须将所有这些逻辑移至 ViewModel。我不知道怎么做,你能请有人解释一下处理吗?我浏览了几个博客,但没有看到这样做的任何用途。

标签: androidmvvmandroid-webviewviewmodel

解决方案


推荐阅读