如何以编程方式设置/编辑webview的内容

Som*_*omk 20 android

有没有办法可以编辑内容以通过java添加或从头开始创建?我找不到任何例子.

mah*_*mah 65

您应该在这里查看WebView文档.

在那里有大量的信息,你会发现:

// OR, you can also load from an HTML string:
String summary = "<html><body>You scored <b>192</b> points.</body></html>";
webview.loadData(summary, "text/html; charset=utf-8", "utf-8");
// ... although note that there are restrictions on what this HTML can do.
// See the JavaDocs for loadData() and loadDataWithBaseURL() for more info.
Run Code Online (Sandbox Code Playgroud)

非常接近页面顶部.