I have String which contains HTML data with <ol>
and <ul>
tag. How to set both in TextView. I am able to set Bullets but not number format. What I did is here:
String html_title = demoList.get(position - 1).getText();
String li = html_title.replace("<li>", " \u25CF");
String mal = li.replace("</li>", "<br/>");
String main_hrml = mal.replace("\t", "\n").replace("\n\n", "\n").trim();
setTextViewHTML(((DemoViewHolderSecond) holder).demoSecondItemInitView.type_1_bodyTxt, main_html);
private void setTextViewHTML(TextView type_1_bodyTxt, String main_html) {
CharSequence sequence = Html.fromHtml(main_html);
SpannableStringBuilder strBuilder = new SpannableStringBuilder(sequence);
URLSpan[] urls = strBuilder.getSpans(0, sequence.length(), URLSpan.class);
for (URLSpan span : urls) {
makeLinkClickable(strBuilder, span);
}
if (main_html.contains("<p>")){
if (!main_html.contains("<ul")) {
GetDeviceResolution getDeviceResolution = new GetDeviceResolution((CoverDetailsActivity) context);
type_1_bodyTxt.setPadding(0, 0, 0, -(int) (getDeviceResolution.setHeight(0.06)));
}else{
GetDeviceResolution getDeviceResolution = new GetDeviceResolution((CoverDetailsActivity) context);
type_1_bodyTxt.setPadding(0, 0, 0, -(int) (getDeviceResolution.setHeight(0.02)));
}
}
type_1_bodyTxt.setText(strBuilder);
type_1_bodyTxt.setLinkTextColor(Color.RED);
removeLine(type_1_bodyTxt, main_html);
type_1_bodyTxt.setMovementMethod(LinkMovementMethod.getInstance());
}