Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get source HTML from encoded EditText in Android

I'm displaying formatted text in an EditText as such:

String msg = <b>Some text here</b>;
EditText txtMsg = (EditText) findViewById(R.id.txtMessage);
txtMsg.setText(Html.fromHtml(msg));

That displays in the EditText as "Some text here." Then, later, I'd like to pull the text from that EditText complete with the tags. However, when I use:

txtMsg.getText().toString();

It just gives me "Some text here" with no formatting.

Any thoughts on this?

like image 273
bkaiser Avatar asked Dec 19 '12 01:12

bkaiser


1 Answers

Try as to get Text with HTML formatting back from EditText:

String msgtext=Html.toHtml(txtMsg.getText());
like image 67
ρяσѕρєя K Avatar answered Oct 20 '22 10:10

ρяσѕρєя K