当前位置: 首页 > news >正文

贵阳网络网站建设吉林百度查关键词排名

贵阳网络网站建设,吉林百度查关键词排名,成都科技网站建设电,怎么开小程序效果 第一步:按如下所示代码创建一个用来高亮显示文本的工具类: public class KeywordUtil {/*** 单个关键字高亮变色* param color 变化的色值* param text 文字* param keyword 文字中的关键字* return*/public static SpannableString highLigh…

效果

在这里插入图片描述

第一步:按如下所示代码创建一个用来高亮显示文本的工具类:

public class KeywordUtil {/*** 单个关键字高亮变色* @param color   变化的色值* @param text    文字* @param keyword 文字中的关键字* @return*/public static SpannableString highLight(int color, String text, String keyword) {SpannableString res = new SpannableString("\t\t\t" + text);Pattern pattern = Pattern.compile(keyword);Matcher matcher = pattern.matcher(res);while (matcher.find()) {int start = matcher.start();int end = matcher.end();res.setSpan(new ForegroundColorSpan(color), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);}return res;}public static SpannableString highLight(int color,String text,String... keyword) {SpannableString res = new SpannableString("\t\t\t" + text);for (String key : keyword) {Pattern pattern = Pattern.compile(key);Matcher matcher = pattern.matcher(res);while (matcher.find()) {int start = matcher.start();int end = matcher.end();res.setSpan(new ForegroundColorSpan(color), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);}}return res;}public static SpannableString highLight(int[] cs,String text,String... keyword) {SpannableString res = new SpannableString("\t\t\t" + text);for (int i = 0; i < color.length; i++) {Pattern pattern = Pattern.compile(keyword[i]);Matcher matcher = pattern.matcher(res);while (matcher.find()) {int start = matcher.start();int end = matcher.end();res.setSpan(new ForegroundColorSpan(cs[i]), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);}}return res;}
}

第二步:在主布局文件中添加三个id值分别为textView1、textView3、textView3的TextView控件,然后修改MainActivity类的代码如下所示:

public class MainActivity extends AppCompatActivity {private android.widget.TextView textView1;private android.widget.TextView textView2;private android.widget.TextView textView3;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);this.textView2 = (TextView) findViewById(R.id.textView2);this.textView1 = (TextView) findViewById(R.id.textView1);this.textView3 = (TextView) findViewById(R.id.textView3);String text = "随着棉花糖的出现,一种新……度,探讨处理权限请求的方法";SpannableString spanStr1 = KeywordUtil.highLight(Color.RED, text, "权限");textView1.setText(spanStr1);SpannableString spanStr2 = KeywordUtil.highLight(Color.RED, text, "棉花糖","权限","安卓");textView2.setText(spanStr2);SpannableString spanStr3 = KeywordUtil.highLight(new int[]{Color.RED,Color.GREEN,Color.BLUE}, text, "棉花糖","权限","安卓");textView3.setText(spanStr3);}
}
http://www.rdtb.cn/news/2087.html

相关文章:

  • 设计网站怎么做网络推广是啥
  • 网站怎么做移动图片不显示不出来英文关键词seo
  • 电子商务网站规划建设与管理超级软文
  • 设计企业网站步骤app注册接单平台
  • 营销型网站建设的特色电销系统软件排名
  • 专业网站建设推荐西安疫情最新数据消息中高风险地区
  • 民族服装的网站建设东莞网站建设推广平台
  • 国内精美网站欣赏重庆森林电影
  • 学生制作网页教程西安seo网站管理
  • 网站可信认证在哪里做全网营销方案
  • 确定网站推广目标黄页引流推广网站软件免费
  • 政府网站域名注册项目营销推广策划
  • 广州外贸网站建设 open六年级上册数学优化设计答案
  • 怎么建设自己淘宝网站首页郑州网络推广报价
  • 17网站一起做武汉推广系统
  • 简易logo图片大全太原关键词排名优化
  • 徐州做网站那家好百度站长中心
  • 如何通审查元素做网站实时新闻最新消息
  • 青岛哪家做网站的公司广告投放代理商加盟
  • wordpress首页文章轮播网站seo服务
  • 怎样做私人网站百度统计平台
  • 营销和运营的区别是什么seo诊断站长
  • 给小孩子做网站网络推广公司经营范围
  • 网站建设免费建站免费源代码百度贴吧官网网页
  • 网站导航是做链接赚钱么整合营销活动策划方案
  • ps做网站ui南宁seo专员
  • 网站图片展示源代码公司网站设计图
  • 转运公司网站建设外贸接单平台网站
  • 高师本科化学实验教学体系建设与创新型人才培养 教学成果奖申报网站b2b网站免费推广平台
  • 做网站哪些好上海网站seo排名优化