Reputation: 63293
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");
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");
But that yielded the same result. Is there something in WebSettings or WebViewClient that controls this behavior I'm missing?
Cheers.
Upvotes: 0
Views: 2764
Reputation: 261
Try this.....
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(header+data, "text/html", "UTF-8");
If you are loading a string of html texts into webView. Then you can use
mWebView.loadData(header+data, "text/html", "UTF-8");
If you have a html file. Then you can use
webView.loadUrl("file:///android_asset/mypage.html"):
Note: Dont forget to put your html file in your assets folder.
Cheers!!! :D
Upvotes: 0
Reputation: 829
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(header+data, "text/html", "UTF-8");
Upvotes: 1