Android的WebView中:更改自动链接显示 [英] Android WebView: Change Auto-Link Display

查看:118
本文介绍了Android的WebView中:更改自动链接显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道的方法来修改的WebView中如何显示的自动链接的文本(电话号码,地址等),视觉风格?或者更确切地说,我可以作出这样的WebView检测样子标准可点击超链接的链接?例如,

Does anyone know of a way to modify the visual style of how the WebView displays auto-linked text (phone numbers, addresses, etc.)? Or more specifically, can I make the links that WebView detects look like standard clickable hyperlinks? For example,

webView.loadData("My phone number is 3035555555", "text/html", "utf-8");

这加载文本到的WebView,它是点击,但它只是看起来像正文的其余部分。我也试过把文本到HTML文件中的资产和做

This loads the text into the WebView and it is clickable, but it just looks like the rest of the body text. I also tried putting the text into an HTML file in assets and doing

webView.loadUrl("file:///android_asset/Test.html");

但是,这产生了相同的结果。有什么在WebSettings或WebViewClient控制这种行为我失踪?

But that yielded the same result. Is there something in WebSettings or WebViewClient that controls this behavior I'm missing?

干杯。

推荐答案

您可以这样做让你在找什么。

You could do this to get what your looking for.


String header = "< ?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
String data = "< html>< body>< a href='tel:555-5599'>508-776-5510
" "< /body>< /html>";

mWebView.loadData(头+数据的text / html,UTF-8);

mWebView.loadData(header+data, "text/html", "UTF-8");

这篇关于Android的WebView中:更改自动链接显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆