android---textview控件学习笔记之显示文本(一)

TextView控件---显示文本(URL,字体,不同大小,颜色的文本)
第一步:
在value  string中添加字符串
<color  name= "">#00ff00</color>
<string  name = "">打电话</string>
第二步:
在layout中操作
<TextView
     //分别设置TextView的属性(宽度、高度、id等)
     layout_width
     layout_height
     id
     padding
/>
<TextView
     layout_width
     layout_height
     id
     padding
     text
     autoLink
     textsize
/>
第三步:
在activity中操作
 //声明两个textview变量
private TextView  textView1,textView2;
//通过对象ID找到该对象
textView1 = (TextView)this.indViewById(R.id.textView1);
textView2 = (TextView)this.findViewById(R.id.textView2);
 
//添加一段html的标识
string html = "<font></font><br>";
hrml += "<>";
hrml += "<>";
 ----设置textview01--
CharSequence charsequence  = Html.fromHtml(html);
//方法Html.fromHtml(html)的返回值为一个charsequence 
textView1.setText(charSequnence);
//设置显示文本内容
textView1.setMovementMethod(LinkMovementMethod.getInstance());
//点击的时候产生超链接
 ----设置textview02-----
string text = "";
text += "";
text +="";
textView2.setText(text);
textView2.setMovementMethod(LinkMovementMethod.getInstance());
 
重点记忆:
CharSequence  ------
Html.fromHtml(html)方法----返回值为一个charsequence,然后调用settext方法
setText(charSequnence)方法----设置显示charsequence,文本textview中的字符串的值
setMovementMethod()方法----显示运动方向
LinkMovementMethod.getInstance()方法---得到实例的方法
原文地址:https://www.cnblogs.com/android-dev/p/android.html