Android如何像这样在webview中显示链接? [英] Android How to Display Links in webview like this?
本文介绍了Android如何像这样在webview中显示链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人知道这样在Webview中显示URL的方法
Does anyone know of a way to Display URL's in webview like this
但是在这里我得到的是这样,这里没有重点,没有单击选项不起作用,请给我一些建议.
But here I am geting Like this here no focus and no click option not working any thing give me some sugessions please..
此代码使用Webview中的显示数据
this code useing display data in webview
webview.getSettings().setJavaScriptEnabled(true);
webview.loadDataWithBaseURL(null, string, "text/html", "utf-8", null);
推荐答案
字符串str =您的文本在这里... http://stackoverflow.com/questions/14576507/android-how-to-display-link-in-webview-like-this
;
String str="Your text goes here... http://stackoverflow.com/questions/14576507/android-how-to-display-links-in-webview-like-this
";
ArrayList<String> myArray = new ArrayList<String>();
myArray.add( "<!DOCTYPE HTML><!-- created HTML PAGE -->");
myArray.add("<head> ");
myArray.add("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" width=100%>");
myArray.add("<meta name=\"viewport\" content=\"width=device-width\">");
myArray.add("<style>");
myArray.add(" p { font-family:Arial, Helvetica, sans-serif;}");
myArray.add("</style>");
myArray.add("</head> ");
myArray.add("<body style=\"background-color: transparent; margin-left:5%; margin-right:5%; \">");
myArray.add("<div >");
Spannable sp = new SpannableString(str);
Linkify.addLinks(sp, Linkify.ALL);
str = Html.toHtml(sp) ;
myArray.add(str);
String myFullString = myArray.toString().replace("[", "").replace("]", "").replace(",", "\n").replace("<", "<").replace(">", ">");
mWebView.loadDataWithBaseURL("about:blank", myFullString ,"text/html", "utf-8", null);
这篇关于Android如何像这样在webview中显示链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文