首页 > 解决方案 > WebView 无法在浏览器和应用程序中打开链接

问题描述

这是我的 WebView 代码:

String mimeType = "text/html";
String encoding = "utf-8";
String htmlText = itemJob.getJobDesc();

String text = "<html><head>"
        + "<style type=\"text/css\">@font-face {font-family: MyFont;src: url(\"file:///android_asset/fonts/custom.otf\")}body{font-family: MyFont;color: #0b0b0b;text-align:left;font-size:15px;margin-left:0px}"
        + "</style></head>"
        + "<body>"
        + htmlText
        + "</body></html>";
webView.loadDataWithBaseURL(null, text, mimeType, encoding, null);

当我单击 WebView 中的链接时,什么也没有发生!如何在浏览器中打开链接?

标签: androidwebview

解决方案


使用这个..它对我来说非常有用。

希望这对你有用

wvDesciption.loadData("<p align='justify'>" + mCouresubModel.getDescription() + "</p>", "text/html; charset=UTF-8", null);

推荐阅读