J
J
JohnDaniels2018-02-16 21:39:29
Android
JohnDaniels, 2018-02-16 21:39:29

How to display formatted text in TextView?

There is a server and two clients - a browser and an android application. Work with one API.
For one of the requests, the server returns a text of the form

Lorem ipsum <span class="text-success">dolor</span> sit amet..

In the application, the text is displayed in a textView.
You need to somehow bring it to the form as in the browser (in this case, highlighting some words with color).
I already googled about Html.fromHtml(), but how to explain to him that class="text-success"this is green text?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
davidnum95, 2018-02-17
@davidnum95

No way, java and android in particular have no idea what css is

A
Alexander Yudakov, 2018-02-17
@AlexanderYudakov

You need to make a SpannableString from the source text:
developer.alexanderklimov.ru/android/theory/spanna...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question