1:使用android:autoLink="all" 只需在textview中加入这个属性 在里面写的文字中包含网址、电话、email的会自动加入连接地址。

如:
android:id="@+id/text1" android:layout_width="match_parent"
android:layout_height="match_parent" android:autoLink="all"
android:text="@string/link_text_auto" />
2:uses a string resource containing explicit tags to specify
links.

如: text2: This is some other
      text, with a link specified
      via an <a> tag.  Use a /"tel:/" URL
      to dial a phone number.
   

    别忘了
    TextView t2 = (TextView) findViewById(R.id.text2);
t2.setMovementMethod(LinkMovementMethod.getInstance());
   
3: builds the text in the Java code using HTML

TextView t3 = (TextView) findViewById(R.id.text3);
t3.setText(Html.fromHtml("text3:  Text with a "
+ "link "
+ "created in the Java source code using HTML."));
t3.setMovementMethod(LinkMovementMethod.getInstance());


4:字符串截取方法
SpannableString ss = new SpannableString("text4: Click here to dial the phone.");

ss.setSpan(new StyleSpan(Typeface.BOLD), 0, 6, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
ss.setSpan(new URLSpan("tel:4155551212"), 13, 17, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

TextView t4 = (TextView) findViewById(R.id.text4);
t4.setText(ss);
t4.setMovementMethod(LinkMovementMethod.getInstance());

  Android中我们为了实现文本的滚动可以在ScrollView中嵌入一个TextView,其实TextView自己也可以实现多行滚动的,毕竟ScrollView必须只能有一个直接的子类布局。只要在layout中简单设置几个属性就可以轻松实现

       android:id="@+id/tvCWJ"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:scrollbars="vertical"   
    android:singleLine="false"      
    android:maxLines="15"            
    android:textColor="#FF0000"
    />

   当然我们为了让TextView动起来,还需要用到TextView的setMovementMethod方法设置一个滚动实例,代码如下

   TextView tv = (TextView)findViewById(R.id.tvCWJ);  
tv.setMovementMethod(ScrollingMovementMethod.getInstance());   // Android开发网提示相关的可以查看SDK中android.text.method分支了解更多

ad_link = (TextView) findViewById(R.id.ad_link);  
                    ad_link.setText(Html.fromHtml(""+Html.fromHtml(mURL.getLabel()+"")));  
                    ad_link.setMovementMethod(LinkMovementMethod.getInstance());

更多相关文章

  1. 【Android】android:padding属性设置对ImageButton无效问题
  2. Android(安卓)的系统属性(SystemProperties)设置分析
  3. Android动画学习笔记-Android(安卓)Animation
  4. linux公社的大了免费在线android资料
  5. 关于android的animation的xml定义中的android:interpolator属性
  6. android List拖动时背景变化
  7. Android属性之excludeFromRecents
  8. 一些关于RelativeLayout属性的用法
  9. 浅谈Java中Collections.sort对List排序的两种方法

随机推荐

  1. 在android的spinner中,实现取VALUE值和TEX
  2. 直接用 Chrome 扩展来回复 Android(安卓)
  3. 写给有 Android(安卓)开发经验的你们
  4. Android和iOS如何连接指定的蓝牙设备
  5. Android卡顿相关原理和排查工具
  6. 通过AspectJX拦截Android重复点击事件
  7. Android官方MVP架构项目解析
  8. Android布局(一)之基本视图View
  9. Android(安卓)getIdentifier()使用
  10. android 项目实战——打造超级课程表一键