Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Add Smiley/Emojis in Edittext?

Tags:

android

How to Add Smiley/Emojis in Edittext?

Any Source code is Available on Internet, if yes Please Give me Link.

Thanks in Advance.

like image 219
Dipak Keshariya Avatar asked Aug 25 '11 11:08

Dipak Keshariya


2 Answers

I am using below code for add Smiley/Emojis in edittext.

ImageGetter imageGetter = new ImageGetter() {
    public Drawable getDrawable(String source) {
        Drawable d = getResources().getDrawable(R.drawable.happy);
        d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
        return d;
    }
};

cs = Html.fromHtml("<img src='" + getResources().getDrawable(R.drawable.happy) + "'/>", imageGetter, null);
edttxtemoji.setText(cs);
like image 147
Dipak Keshariya Avatar answered Oct 23 '22 20:10

Dipak Keshariya


Android may not support some special characters, but here is the tutorial anyways:

On a PC, I believe either Alt + 1 or Alt + 2 makes a smiley face.

This website provides an excellent tutorial for how to do alt codes, along with what alt code combination does what.

For a Mac, you can hold "Option + Command + T" down to open a list of special characters. From there, open the category "Miscellaneous." Your smiley is in there.

Is this what you are looking for? If not, just let me know :). When all else fails, you could just use an image of a smiley-face.

EDIT: I'm using a Mac. I opened TextEdit, followed my above tutorial for the Mac, generated a smiley face, cut the smiley face, and pasted it into the Java code. It worked for me. If it's not working for you, try copying this:

EditText mEditText = null;
mEditText.setText("☺");

EDIT 2: I thought Martin was looking for just a smiley, not a window of Emoji's. Currently, there is no source code to open this window - only a separate app that does this, which can be found at this link or this link.

like image 26
Mxyk Avatar answered Oct 23 '22 18:10

Mxyk