【问题标题】:How to programmatically set / edit content of webview如何以编程方式设置/编辑 webview 的内容
【发布时间】:2011-09-06 13:37:37
【问题描述】:

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

【问题讨论】:

    标签: android


    【解决方案1】:

    WebView.loadData 可以直接传递 HTML 字符串。我在我的应用程序中使用从头开始创建的“页面”,它只是用 HTML 格式化

    【讨论】:

      【解决方案2】:

      您应该查看 WebView 文档here

      在其他大量信息中,您会发现:

      // 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.
      

      非常接近页面顶部。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-02-21
        • 2017-11-22
        相关资源
        最近更新 更多