I, want to convert my TextView in Html format. when required. so i used the following code. but i am not getting how to use result variable with setText.
@Override
public void onStart() {
super.onStart();
groupDeals.addSnapshotListener(new EventListener<DocumentSnapshot>() {
@Override
public void onEvent(@javax.annotation.Nullable DocumentSnapshot documentSnapshot, @javax.annotation.Nullable FirebaseFirestoreException e) {
if (e != null) {
return;
}
if (documentSnapshot.exists()) {
String title = documentSnapshot.getString(GROUP_DEALS_KEY_DEALS);
Spanned result;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
result = Html.fromHtml(GROUP_DEALS_KEY_DEALS, Html.FROM_HTML_MODE_LEGACY);
} else {
result = Html.fromHtml(GROUP_DEALS_KEY_DEALS);
}
tv_groupDeals.setText(title);
}
}
}
);
}
I, have tried the some solutions. but not getting appropriate result. i tried like this:
tv_groupDeals.setText(title + result);
But it does't work.
I believe GROUP_DEALS_KEY_DEALS is not a HTML text to begin with, you can only use a HTML string in HTML.fromHtml() methods.
checkout this link to know how to use HTML strings in TextView.