I have a .txt file inside my assets folder that has a massive HTML in it...
I call it to a string, remove some HTML tags using JSoup Library, and set this string as a TextView's text:
InputStream is;
TextView tv = (TextView)findViewById(R.id.tv);
String html;
try {
is = getAssets().open("html.txt");
html = convertStreamToString(is);
} catch (Exception e) {
e.printStackTrace();
}
Document doc = Jsoup.parse(html);
Elements links = doc.select("a[href]");
for (Element link : links) {
doc.select("a").unwrap();
}
doc.select("title").remove();
tv.setText(fromHtml(html));
It results in a TextView showing a really big and beautiful formatted HTML code
When the user touches any word in that TextView, I want to change the word's background color, marking it, and storing that mark to be marked again when user restart the application... How could I achieve that?
EDIT:
Also, how could I work with Spannable
and Html.fromHtml()
together?