Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

display smiley in textview and edittext in android

hello i am developing chat application in which i want to insert smiley i have not much idea about it how to integrate and display in it can u give me suggestion for doing the same ?

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);
System.out.println("cs is:- " + cs);
edttxtemoji.setText(cs);

i found this code, in this it uses images, is this feasible ? or there is another solutions ? please give me better solution for this thanx in advance

like image 728
Ramesh Solanki Avatar asked Feb 17 '12 12:02

Ramesh Solanki


1 Answers

Yes there is another way for showing smiley within the TextView or EditText. Build a Spannable text using ImageSpanand then setText the Spannable to TextView or EditText. Here is an post for the same.

like image 59
Lalit Poptani Avatar answered Sep 30 '22 18:09

Lalit Poptani