复制和粘贴的EditText图像 [英] copying and pasting image in Edittext

查看:135
本文介绍了复制和粘贴的EditText图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目使用RichTextEditor完成几乎所有功能。我可以插入图像,并可以保存图像,并也越来越图像并打开文件时again.I是卡在一个点上,即所有样式文件。除了图像复制的EDITTEXT的所有内容,而粘贴的时候所有的东西糊了,但在图像方面我有这样的

I am on the project RichTextEditor and completed almost all functionality. I can insert image and can save the file with image and also getting the image and all styles while opening the file again.I am stuck at one point ie. when copying all the content of the Edittext, while pasting except Image all things got paste, but in image area i got like this

任何想法或变通方法来复制和粘贴图像。 谢谢你。

any idea or workaround to copy and paste the image. Thanks.

推荐答案

我有同样的问题。获得EDITTEXT领域的字符串后,我发现了目标文件的性格,然后将它与图像的链接取代。我创建了一个ArrayList中存储的图像链接。而且,我想我需要赶上删除操作。如果图像被删除,删余其图像列表中的链接。下面是code我用它来取代目标文件的性格。

I have the same problem. After get the editText field's string, I find the "obj" character, and then replace it with image's link. I created a ArrayList to store the images' links. And moreover, I think I need to catch the delete action. If an image is deleted, I deleted its link in the image list. Below is the code I use to replace the "obj" character.

private String replaceSpecialCharactorFromNote(){
    String noteString = edt_note.getText().toString();
    char[] noteCharacters = noteString.toCharArray();
    for(int i=0; i<noteCharacters.length; i++){
        if((int)noteCharacters[i] <1 || (int)noteCharacters[i]>254 ){//compare the ascii code
            Log.i("the first abnormal charactor is ", "" + noteCharacters[i]);
            if(imageIndex < imgsList.size()){
                Log.i("replace triggered", "special char index is "+i);
                Log.i("replace triggered", "replaced image index is "+imageIndex);
                Log.i("replace triggered", "image is "+imgsList.get(imageIndex));
                String beforeString = noteString.substring(0, i);
                String afterString = noteString.substring(i+1);
                noteString = beforeString + imgsList.get(imageIndex) + afterString; 
                Log.i("replace triggered", "note is "+noteString);
            }
            imageIndex++;
        }
    }
    return noteString;
}

总体来说,我不认为我做的方式是解决问题的最好办法。最好的办法可能是创建一个自定义字段来处理它。

Overall, I do not think the way I did is the best way to solve the problem. The best way probably will be to create a custom field to handle it.

这篇关于复制和粘贴的EditText图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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