android - 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 中的链接时,什么也没有发生!如何在浏览器中打开链接?
解决方案
使用这个..它对我来说非常有用。
希望这对你有用
wvDesciption.loadData("<p align='justify'>" + mCouresubModel.getDescription() + "</p>", "text/html; charset=UTF-8", null);
推荐阅读
- amazon-product-api - 如何通过 ASIN 从亚马逊检索所有书籍类别?
- javascript - 在javascript中的promise-aware for循环中更新对象属性的问题
- python - 如何计算一个术语在使用python时出现的文档数?
- r - 在 R 中导入和合并多个 CSV
- javascript - Service Workers - 选择性地选择资源
- java - 在 Spring Boot 中自动检测 HTTP 请求的 Content-Type 匹配正文文件类型?
- javascript - 如何使用拆分为数组的字符串搜索数组?
- excel - excel在end with和for循环之间崩溃?
- linux - faillock 在 RHEL6 上将正确的密码标记为错误
- python-3.x - Python3 使用自制软件安装但未使用更新版本