开发者

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 &lt;.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜