How to set unicode in textview to show emoji in android?

不打扰是莪最后的温柔 提交于 2019-12-12 12:13:28

问题


I am getting some Unicode string(emoji icons) from server in json string format.

My problem is strange and I am trying for last two days to resolve this issue. When I parse json and store all the Unicode string in an ArrayList<String> and try to set the text on TextView by getting value from the same ArrayList then it shows Unicode characters as :

Ghcghchgc\ud83d\ude03\ud83d\ude03fyju\ud83d\ude0c6\u20e3

and when the same string I set on textview by passing static value as : textview.settext("Ghcghchgc\ud83d\ude03\ud83d\ude03fyju\ud83d\ude0c6\u20e3")

then the textview is showing perfect emojis.

I am stuck at this point. Can anybody please help me to resolve this issue or tell me if I am doing something wrong.


回答1:


This sounds like you want to unescape your string that you've got from JSON. If you don't mind adding a library, Apache Commons has a String.unescapeJava function which does what you need. If you don't want to add that library, see this answer.



来源:https://stackoverflow.com/questions/25137006/how-to-set-unicode-in-textview-to-show-emoji-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!