Learn Android also has a period of time, has been their own groping, a variety of Internet search information, but also understand that can not blindly take time to share some of their own experience.
in recent days have been writing about the Android emoji input small example, there are many online source and implementation ideas, I myself also saw a Emojicon open source project, Analysis of the implementation of the principle of a few hours did not understand, Emojicon emoticons have been a certain encoding, the key is their own level is limited, on the coding that piece is rarely involved.
first of all, to realize emoji first to understand some related classes and inheritance relationship.
Characterstyle:
The implementation class can set the style of the character.
Spannable:
This interface is implemented indirectly by Charsequence, and the SetText method of TextView in Android is to receive the charsequence that must be remembered.
A simple implementation method:
Use the name of the emoji file to generate a text representation of the emoji in accordance with the rules you have designed. Set the emoji text to TextView or EditText, where the TextView are going to inherit their own later rewrite some methods, set the emoji text to TextView in the middle to find the characters TextView, Find the emoji text inside and replace it with a picture by spannable.
To define a class:
Emoji:
The entity class.
Absemojifactor
Emoji abstract factory, loading emoji files.
Emojimanager
Search emoji text for centralized management of emoji generated by absemojifactor.
The other is the UI layout, adapter and so on, not the core part of it is not written, the last image of the code.
The UI goes just fine haha.
Project code is utf-8 garbled, please modify the code, after downloading with compression software decompression on the line.
Baidu Network disk Download: Http://pan.baidu.com/s/1jGzHi8Q