vxh.viet
6/16/2016 - 3:20 AM

How to put Emoji in AlertDialog, Text field....?

How to put Emoji in AlertDialog, Text field....?

Source: StackOverflow, FileFormat, timwhitlock, AndroidDeveloper

Question: How to put Emoji in AlertDialog, Text field....?

Answer:

  • To put it directly in the strings.xml just go to FileFormat and look for C/C++/Java source code. Example:

<string name="random_emoji">"Just some random Emoji \uD83D\uDE05)."</string>

Possibly crashing on some device see StackOveflow CONFIRMED: crashed on Oppo F1

  • Programatically adding it:

Using a string placeholder %1$s and filling in the Emoji in code like this:

// greeting_3 is defined as: "hello there %1$s!"
String s = context.getString(R.string.greeting_3, "");
// OR:
String s = context.getString(R.string.greeting_3, new String(Character.toChars(0x1F61C)));