2016-11-10 79 views
2

我使用这个表情符库将表情符号的代码串

https://github.com/hani-momanii/SuperNova-Emoji

这个库有一个自定义的TextView它可以使表情符号。如何设置该文本视图的文本以显示表情符号?

例如,我尝试这样做,也没有工作:

String happy = " Feeling happy U+1F601 "; 
emojitextview.setText(happy); 
+0

(HTTP [如何设定在机器人的TextView的unicode的表情符号]的可能重复: //stackoverflow.com/questions/26893796/how-set-emoji-by-unicode-in-android-textview) –

回答

3

切换出 'U +' 为加 '0x':

int unicode = 0x1F601; 

String happy = "Feeling happy " + getEmojiByUnicode(unicode); 

并把它通过一个辅助功能:

public String getEmojiByUnicode(int unicode){ 
    return new String(Character.toChars(unicode)); 
} 

ps如果它仍然无法正常工作,您可能需要设置TextView的使用支持表情符

从字体: how set emoji by unicode in android textview