1

In my app, i want to save blog post in firebase realtime database and want to upload my post with symbol like this

enter image description here

Is there any way? I didn't found any. My code

mPost.setText(fromHtml(dataSnapshot.child("post").getValue().toString()));

@SuppressWarnings("deprecation")
    public static Spanned fromHtml(String html){
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            return Html.fromHtml(html, Html.FROM_HTML_MODE_LEGACY);
        } else {
            return Html.fromHtml(html);
        }
    }

for <ul><li>Item 1</li><br><li>Item 2</li></ul>

Output:
Item 1
Item 2

1 Answers1

1

You can use html string to upload it.

For example if you want to upload an unordered list:

Upload following string in firebase db
"stringVal" : "<b>Title</b><br><br>&#8226; item1<br>&#8226;item2<br>&#8226;item3"

And display it in android (using java) like this:

TextView foo = (TextView)findViewById(R.id.foo);
foo.setText(Html.fromHtml(<String from firebase db>));

Output:

Title

  • item1
  • item2
  • item3

Reference : link

mark922
  • 1,136
  • 2
  • 11
  • 20