设置代码高亮
来源:互联网 发布:网络写手如何取名 编辑:程序博客网 时间:2024/05/22 17:46
package com.example.helloworld;
import android.os.Bundle;
import android.app.Activity;
import android.graphics.Color;
//import android.text.Html;
import android.widget.TextView;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
//import android.text.SpannableString;
//import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView tv=(TextView)findViewById(R.id.textview); --创建一个textview控件
String str="thisismyfirst class";--声明一个字符串变量
SpannableStringBuilder style=new SpannableStringBuilder(str); 将str字符串载入SpannableStringBuilder对象中
--分段显示str字符串的字体的颜色,ForegroundColorSpan(Color.RED)表示是1,到4这个范围内的字符的颜色是红色,
--SPAN_EXCLUSIVE_INCLUSIVE 表示1到4这个范围内的字符不包含第一个但是包含第4个字符,也就是从第二个字符开始到第四个字符,他的颜色都是红色
style.setSpan(new ForegroundColorSpan(Color.RED), 1, 4, Spannable.SPAN_EXCLUSIVE_INCLUSIVE); style.setSpan(new ForegroundColorSpan(Color.BLUE), 5, 7, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
tv.setText(style);
}
}
- 设置代码高亮
- OneNote 设置代码高亮
- Eclipse设置代码高亮,设置代码样式
- 设置word文本代码高亮
- word中设置代码高亮
- OneNote2016如何设置代码高亮
- KindEditor4.1.4代码高亮显示设置
- 代码设置宽高
- 新浪博客设置代码高亮的方法
- jQuery编辑器KindEditor4.1.4代码高亮显示设置
- Lucene之——设置高亮核心代码
- Visual Assist X Options 设置代码高亮颜色
- 关于CKEditor代码高亮设置--懒人版
- jQuery编辑器KindEditor4.1.4代码高亮显示设置
- EditPlus 编程背景色设置与代码高亮
- PhpStorm支持dwt文件代码高亮显示设置方法
- vim编辑器代码高亮/显示行号/自动缩进设置
- java代码设置布局的宽和高
- 引用 typedef和typename关键字
- AcDbDateBase
- visual studio 正则表达式查找替换
- 转(ObjectARX杂碎--(学习指南及书籍))
- 转(ARX编程各种技术处理)
- 设置代码高亮
- AuToCAD启动自定义加载程序研究(转)
- (转)开源应用程序打包工具
- VC++得到系统特殊文件夹路径(转)
- 常用传输术语OC/STM_SDH/SONET
- 【转载】\t\tAutoCAD2008系统变量一览表(1 字母打头(3 A B C ))
- 【转载】\t\tAutoCAD2008系统变量一览表(2 字母打头(D))
- 【转载】\t\tAutoCAD2008系统变量一览表(3 字母打头(E F G H))
- 【转载】\t\tAutoCAD2008系统变量一览表(4 字母打头(I L))