TextView does not display < symbol
TextView does not display the <
symbol.
How can I make it so i开发者_如何转开发t does?
HTML Encoding
Try htmlEncode() from android.text.TextUtils
TextUtils.htmlEncode("My String with <");
HTMLDecoding
To decode HTML encoded Strings use fromHtml(htmlEncodedString) from android.text.Html
Html.fromHtml(htmlEncodedString).toString();
[EDIT] You asked how you must proceed after retrieving the TextView by its ID from the resource XML. You would set its text like that:
TextView t=(TextView)findViewById(R.id.textView);
t.setText(TextUtils.htmlEncode("My HTML encoded String with <"));
Don't forget to import android.text.TextUtils
first!
Use the HTML entity <
.
精彩评论