嵌入的表情符号(表情图像)定制的Andr​​oid softkeyboard [英] Embedding emoji(emoticons images) to custom softkeyboard android

查看:371
本文介绍了嵌入的表情符号(表情图像)定制的Andr​​oid softkeyboard的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个自定义的软键盘(IME),我们可以添加自定义的表情符号。

I have created a custom soft Keyboard(IME) where we can add custom emoji.

每当我尝试为加我的表情吧。它覆盖最后一个文本输入。我的意思是不追加的表情,除非它覆盖它。我如何能添加表情符号到currentInputConnection

Whenever i try to add my emoticons to it. it override the last text entered. i mean it dont append the emoticons unless it override it. how can i add emoji to currentInputConnection

例如:

i image write  hello image abcimage          ///where image represents emoji

变得

i image write hello image image

//我可以空格后添加图片或易反复我可以轻松地添加图片。

// and i can add image after space easily or i can repeatedly add images easily .

当我添加追加​​到表情符号文本,但是当我输入一些文字后添加表情符号它删除文本,然后添加它的自我(绘文字图像)。

when i add text it appends to emoji but when i add emoji after entering some text it remove the text and then add it self(emoji image).

只是用于测试目的,我把表情符code到shift键

Just for testing purpose i put emoji code to shift key

问题code

else if (primaryCode == Keyboard.KEYCODE_SHIFT) 
        {
        //  this.handleShift();

            //this.mComposing.append(getSmiledText(getApplicationContext(), ":)"));

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

                Spanned cs = Html.fromHtml("<img src='" + getResources().getDrawable(R.drawable.e041) + "'/>", imageGetter, null);

              //  getCurrentInputConnection().commitText(cs, 1);

               // this.mComposing.append(cs);


            //getCurrentInputConnection().commitText(getSmiledText(getApplicationContext(), ":)"), 1);


             getCurrentInputConnection().beginBatchEdit();


             getCurrentInputConnection().commitText(cs, 1);

             getCurrentInputConnection().endBatchEdit();


            //getCurrentInputConnection().setComposingText(cs, 1); // it is giving wrong 


        } 

和尝试多种方式来解决这个问题,一些试图codeS在评论中所示

And tried multiple ways to solve it ,some tried codes are shown in comments

简单的话:我要追加的表情符号图像文字,但是当我添加图片到文字,它去掉书面文字,我该如何解决。 完整的源代码无法显示这是漫长的。问我,如果你需要任何方法在我的课

Simple Words : I want to append emoji image to text, but when i add image to text, it remove the written text, how can i solve. full source can't be shown it is lengthy. Ask me if you need any method in my class

相关链接:

在android系统添加自定义图像作为表情符号

add custom image as Emoji in android

无法将图像添加到我的键盘服务

<一个href=\"http://stackoverflow.com/questions/16768930/implementations-of-emoji-emoticon-view-keyboard-layouts\">Implementations绘文字(表情)查看/键盘布局

在此先感谢。

推荐答案

我也试过相同的,但总是有目标文件.Atlast我找到了一个解决方案,试试这个。

I also tried for the same but always got "obj".Atlast I found a solution try this.

而不是增加可绘制只是他们的UNI codeS这样添加表情符号。

Instead of adding drawables just add emoticons by their uniCodes like this..

getCurrentInputConnection()commitText((CharSequence的)\\ ud83c \\ udfb5,1);

它的工作对我来说perfectly.and也将从code删除beginBatchEdit和endBatchEdit。

Its working for me perfectly.and also remove beginBatchEdit and endBatchEdit from your code.

感谢

这篇关于嵌入的表情符号(表情图像)定制的Andr​​oid softkeyboard的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆