php:细说PHP之文章发布操作实2

TextView tv = (TextView)findViewById(R.id.tv);

String str ="我要变成红色字体,红色字体,红色字体";

String[] str2 ={"我","变","红"};

tv.setText(turnSomeWordsToRed(str,str2));



public SpannableStringBuilder turnSomeWordsToRed(String OriginStr,String[] strForRed) {

// TODO Auto-generated method stub


SpannableStringBuilder styleStr = new SpannableStringBuilder(strTitle);

for(int i=0;i<strForRed.length;i++) {

int startPosition = strTitle.indexOf(strForRed[i].trim());

int endPosition = startPosition+strForRed[i].length();

styleStr.setSpan(new ForegroundColorSpan(Color.RED), startPosition, endPosition, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);

}

return styleStr;

}

php:细说PHP之文章发布操作实2,布布扣,bubuko.com

php:细说PHP之文章发布操作实2

上一篇:《HTML 5网页开发实例详解》样章、内容简介、前言


下一篇:VB.NET-轻松判断文本框是否为空,一键清空文本框内容