Quite simple problem:
I have some TextView
TextView textView = (TextView) findViewById(R.id.textView1);
I set styled text (with <b>
tags or any other tags)
textView.setText(Html.fromHtml("Simple text. <b>Bold text</b>. Simple text."));
Problem: when I call textView.getText()
I receive Simple text. Bold text. Simple text.
. <b>
tags have disappeared somehow.
How can I retrieve text from TextView with its formatting?
@Wand Maker's assumption (see comments in question) was correct
Following code works:
TextView textView = (TextView) findViewById(R.id.textView1);
textView.setText(Html.fromHtml("Simple text. <b>Bold text</b>. Simple text."), TextView.BufferType.EDITABLE);
String almostSameText = Html.toHtml(tv.getEditableText()).toString();
The result is: <p>Simple text. <b>Bold text</b>. Simple text</p>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With