Today, let's talk about Spannablestring and Imagespan class.
Bitmap Bitmap = null;
Bitmap = Bitmapfactory.decoderesource (Getresources (), imageids[arg2% imageids.length]);
The first parameter includes the entire picture resource, and the second specifies an ID
Imagespan Imagespan = new Imagespan (neighborcommunicationmessageactivity.this, bitmap);
//edit box to add pictures to the class, Let the picture replace the specified text, such as hehe is actually equivalent to can be replaced by each other. I'll let you choose when you type.
String str = NULL;
if (arg2<10) {
str = "F00" +ARG2;
}else if (arg2<100) {
str = "F0" +ARG2;
}else{
str = "F" +ARG2;
}
spannablestring spannablestring = new spannablestring (str);
Spannablestring.setspan (Imagespan, 0, 4, spannable.span_exclusive_exclusive);
//
Content.append (spannablestring);
TextView combined with spannablestring the use of the encyclopedia inside there is aReplace text with ImagespanThe specific is:spannablestring ss = new Spannablestring ("CCCCCCCCCCCCC stepping");
drawable d = getresources (). getdrawable (R.drawable.icon);
d.setbounds (0, 0, d.getintrinsicwidth (), D.getintrinsicheight ());
//Create Imagespan
Imagespan span = new Imagespan (d, imagespan.align_baseline);
//Replace text with Imagespan
Ss.setspan (span,,, spannable.span_inclusive_exclusive);
Txtinfo.settext (ss);
At this time Content.append (spannablestring), actually is the picture expression into edittext inside.