Android implementation emoji input

Source: Internet
Author: User

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

    

  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.