Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
177 views
in Technique[技术] by (71.8m points)

java - Why doesn't Html.fromHtml not working for String in Android?

enter image description here

One String value is coming from my firebase:

if (task.isSuccessful()) {
    //   binding.contentMain.noData.setVisibility(View.GONE);
    for (QueryDocumentSnapshot document : Objects.requireNonNull(task.getResult()))
        postMap.putAll(document.getData());

    try {
        if (postMap != null)
            //binding.desc1.setText(Objects.requireNonNull(postMap.get(CONTENT)).toString());
            binding.desc1.setText(Html.fromHtml(Objects.requireNonNull(postMap.get(CONTENT)).toString()));
    } catch (Exception e) {
        e.printStackTrace();
    }
}

Now, I'll tell you what is coming inside String from Firestore, Actually I only manually written as a String field inside Firestore collection.:

This is the first text. 

 This is a second text. 
 This is the third text. 

 Done. 

Make sure that above line is just one String/firestore field.

In firestore, I stored the above value as a String, and fetching that value and showing it in Android. But it is not taking a new line. Instead, it is showing written along with other characters.

I tried with and without HTML. with and .

UPDATE: You can see below image how I stored in Firestore. https://drive.google.com/open?id=19yry9top_W8LREw5SEaZKWYWSlnCP1io

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...