我想加入一些图像分成的EditText下面代码:Android的插入图像插入的EditText
Bitmap myBitmap = BitmapFactory.decodeFile(APP.DIR_APP + APP.IMAGE + "/ok.png");
Drawable mDrawable = new BitmapDrawable(getResources(), myBitmap);
ImageSpan imageSpan = new ImageSpan(mDrawable);
SpannableStringBuilder builder = new SpannableStringBuilder();
builder.append(contentText.getText());
String imgId = "[img=1]";
int selStart = contentText.getSelectionStart();
builder.replace(contentText.getSelectionStart(), contentText.getSelectionEnd(), imgId);
builder.setSpan(imageSpan, selStart, selStart + imgId.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
contentText.setText(builder);
此路径APP.DIR_APP + APP.IMAGE + "/ok.png"
是正确的,我检查与file.exists()
和真正的回报,但我不没有选择图片到编辑文字
看到这个答案 - https://stackoverflow.com/a/3704545/5550161 –