Android- Chat application - Convert editbox emoticons in string ;) format to save in database

StackOverflow https://stackoverflow.com/questions/16793220

  •  30-05-2022
  •  | 
  •  

문제

I have developed a chat application in android and I want to add the Emoctions feature with my application. Till now i have implement this feature with gridview, in which when i enter emoji with text it appears in editText. but what i want to save this in database with :) formate. Hv created mapping of image & :) string But cant get how to save by changing it.

For edittext i hv used following code:

    ImageGetter imageGetter = new ImageGetter() {

        @Override
        public Drawable getDrawable(String source) {
            Drawable d = getResources().getDrawable(emojis.images[index]);
            d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
            return d;
        }
    };
    cs = Html.fromHtml(
            "<img src ='"
                    + getResources().getDrawable(emojis.images[index])
                    + "'/>", imageGetter, null);
    writeboard.setText(cs);

Plz help me to perform database saving and showing it in textview. Thanks.

도움이 되었습니까?

해결책

I got answser by spannable method.

With in spanable method i am comparing string with pattern so whenever that pattern matches in text, it will show emoji of relavent pattern.

I called this method when ever i selected emoji from gridview, on msg recieved, and ontextchanged so whenever it found pattern it will changed to emoji. so like this it is saving data in text formate of :) and showing emoji as icon.

Hope this will be helpful.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top