##之间的内容是代表一个话题,@和:之间的是转发这条微博的人,也高亮显示,||代表上一次转发此微博的。url地址也高亮显示。
这个是什么组件啊?是TextView,不会吧?TextView能显示图片吗?肯定能呀。
主要是用到了SpannableString,ForegroundColorSpan,ImageSpan这3个类.
String origtext = data.getString("origtext"); SpannableString spannable = new SpannableString(origtext); spannable = TextUtil.decorateFaceInStr(spannable, RegexUtil.getStartAndEndIndex(origtext, Pattern.compile("\\/[\u4e00-\u9fa5a-zA-Z]{1,3}")), getResources());//解析成本地表情 spannable = TextUtil.decorateRefersInStr(spannable, RegexUtil.getStartAndEndIndex(origtext, Pattern.compile("@.*:")), getResources());//高亮显示微薄转发,回复者昵称
public static List
public static SpannableString decorateVipInStr(SpannableString spannable,List> list,Resources resources){ int size = list.size(); Drawable drawable = null; if(list!=null&&list.size()>0){ for(int i=0;i map = list.get(i); drawable = resources.getDrawable(R.drawable.vip); drawable.setBounds(0, 0, drawable.getIntrinsicWidth(),drawable.getIntrinsicHeight()); ImageSpan span = new ImageSpan(drawable,ImageSpan.ALIGN_BASELINE); spannable.setSpan(span, (Integer)map.get("startIndex"), (Integer)map.get("endIndex"), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } } return spannable; } public static SpannableString decorateTopicInStr(SpannableString spannable,List > list,Resources resources){ int size = list.size(); Drawable drawable = null; CharacterStyle foregroundColorSpan=new ForegroundColorSpan(Color.argb(255, 33, 92, 110)); if(list!=null&&list.size()>0){ for(int i=0;i map = list.get(i); spannable.setSpan(foregroundColorSpan, (Integer)map.get("startIndex"), (Integer)map.get("endIndex"), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } } return spannable; }