你好,我制作了一个程序,可以将字符串突出显示到 webview(android) 中,我坚持用这段代码替换有颜色的字符串
String[] arr = "LION SAVANA".split(" ");//i split textview string to have words (here we suppose that user entered : "lion savana"
String finalText = "the lion is a species of mamifer living into the savana"
for (String ss : arr) {
if (ss.length() > 2) {
ss = ss.replace("*","");
finalText = finalText.replaceAll("(?i)" + ss, "<b style = \"color:#2575ff\";>" + ss + "</b>");//finally here i replace all lion or savana occurrences by blue ones -> but i not …Run Code Online (Sandbox Code Playgroud)