EditText:复制时将图像更改为字符串?
我有一个可以包含图像(表情符号)的 EditText。当我复制此文本并将其粘贴到其他地方时,我得到“obj”正方形而不是图像。
有没有办法更改复制时要放入剪贴板的内容(以便我可以将图像对象更改为字符串)?
编辑1: 我想我可以创建自己的 EditText 类并重写复制文本时使用的方法。有人知道我应该重写什么方法吗?我尝试了“getText()”,但它不起作用...
编辑2: 实际上,它有效,但是重写此方法会更改 EditText 中的文本,因此它仍然没有用...
I have an EditText that can contain images (emoticons). When I copy this text and paste it elsewhere, I get "obj" square instead of the image.
Is there a way to change what is to be put in clipboard when copying (so that I can change the image object into a string)?
Edit 1:
I guess I could create my own EditText class and override the method that is used when copying the text. Anyone knows what method should I override? I tried "getText()", but it doesn't work...
Edit 2:
Actually, it worked, but overriding this method changes the text in EditText, so it still isn't usefull...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
也许这会有所帮助:
Maybe this will be helpful:
您是否尝试过创建图像的字节数组?
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bm.compress(Bitmap.compressFormat.PNG, 100, baos); //bm是位图对象
byte[] b = baos.toByteArray();
Have you tried creating a byte array of the image?
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.PNG, 100, baos); //bm is the bitmap object
byte[] b = baos.toByteArray();
不知道你是否解决了问题。我刚刚在 stackoverflow_1527918 上发表了一篇文章,
我使用的方法是对
editText.getText( ).toString
查找“obj”字符。然后将其替换为图像的链接。如果您有更好的想法,请告诉我。谢谢。
I do not know whether you solve the problem or not. I just have a post at stackoverflow_1527918
The method I used is to do a linear search on the
editText.getText().toString
to find the "obj" character. And then replace it with the image's link.If you have any better idea, please tell me. Thank you.