2

So I used Java using a button that makes selected EditText to bold. At the edittext it shows bold, then I send the data to firebase database, then retrieve it.

The problem is that Firebase doesn't save the style of the text, so it doesn't display the bold at the retrieve text.

Any solutions for that?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Dor Furman
  • 55
  • 1
  • 8

2 Answers2

1

Firebase is only save your data, so it's not support save a bold text. Instead, you can save it yourself.

  1. Add another field beside text field in firebase to save style of text, and handle it when you retrieved from firebase

    { "text": "some text", "style": "bold" }

  2. Save data with html format. Like this

    editText.setText(Html.fromHtml("< b>" + myText + "< /b>");

phapli
  • 627
  • 6
  • 16
0

I tried this and it gave me a decent results afer you paste the text in EditText

final String keepFormat=TextUtils.htmlEncode(mytext.getText()+"");

//------------------------------------------------------- to receive it from Firebase let's say you gonna set this text to a TextView textView;

    textView.setText(TextUtils.htmlEncode( aboutString));

//--------------------------------------------------------------- if you take a look at the Firebase Realtime database console you will notice that your text has extra code in it to fill the spaces and keep the text format the same way it was in the EditText

amr eshak
  • 31
  • 2