日期:2014-05-17 浏览次数:20625 次
ImageGetter imgGetter = new Html.ImageGetter() { @Override public Drawable getDrawable(String source) { Drawable d=null; try { URL aryURI = new URL(source); /* 打开连接 */ URLConnection conn = aryURI.openConnection(); conn.connect(); /* 转变为 InputStream */ InputStream is = conn.getInputStream(); /* 将InputStream转变为Bitmap */ //Bitmap bm = BitmapFactory.decodeStream(is); /* 关闭InputStream */ /*添加图片*/ d=Drawable.createFromStream(is, "111"); is.close(); } catch (IOException e) { e.printStackTrace(); } d.setBounds(1, 1, 45, 45); return d; }
public class MyHtmlTagHandler implements TagHandler { public void handleTag(boolean opening, String tag, Editable output,XMLReader xmlReader) { if(tag.equalsIgnoreCase("strike") || tag.equals("s")) { processStrike(opening, output); } } private void processStrike(boolean opening, Editable output) { int len = output.length(); if(opening) { output.setSpan(new StrikethroughSpan(), len, len, Spannable.SPAN_MARK_MARK); } else { Object obj = getLast(output, StrikethroughSpan.class); int where = output.getSpanStart(obj); output.removeSpan(obj); if (where != len) { output.setSpan(new StrikethroughSpan(), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } } } private Object getLast(Editable text, Class kind) { Object[] objs = text.getSpans(0, text.length(), kind); if (objs.length == 0) { return null; } else { for(int i = objs.length;i>0;i--) { if(text.getSpanFlags(objs[i-1]) == Spannable.SPAN_MARK_MARK) { return objs[i-1]; } } return null; } } }