zoukankan      html  css  js  c++  java
  • 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()方法---得到实例的方法
  • 相关阅读:
    vue技术分享之你可能不知道的7个秘密
    JVM知识总结-运行时区域划分
    如何使用加多宝(jdb)在linux下调试Java程序
    RabbitMQ 高可用之镜像队列
    Gson格式转换Integer变为Double类型问题解决
    IPv6地址表示方式
    MySQL truncate()函数的使用说明
    Java 实现判断 主机是否能 ping 通
    MySQL 性能优化系列之一 单表预处理
    Linux 查看CPU和内存的使用情况
  • 原文地址:https://www.cnblogs.com/android-dev/p/android.html
Copyright © 2011-2022 走看看