Android软件开发之TextView详解


TextView的API 中文文档中 说明它的结构

结构

java.lang.Object

Android.view.View

android.widget.TextView

直接子类:

Button, CheckedTextView, Chronometer, DigitalClock, EditText

间接子类:

AutoCompleteTextView, CheckBox, CompoundButton, ExtractEditText,MultiAutoCompleteTextView, RadioButton, ToggleButton

1.TextView中链接手机号码/网页/邮件/地图

android:autoLink的可选值为(none/web/email/phone/map/all) 设置一个URL链接 ,可以点击访问。

例如:android:text="拨打手机:13888888888"

android:autoLink="phone"

这里设置了一个链接为手机的autoLink  它会自动设别数字 过滤掉字符串"拨打手机:" 从而点击号码后会转跳到系统拨号码的界面可以拨打电话。

拨打手机号码:

  1. <TextView android:id="@+id/textView0"  
  2.           android:layout_width="fill_parent"  
  3.           android:layout_height="wrap_content"   
  4.           android:textColor="#FF0000"  
  5.           android:textSize="18dip"  
  6.           android:background="#FFFFFF"  
  7.           android:text="拨打手机:13888888888"   
  8.           android:gravity="center_vertical|center_horizontal"  
  9.           android:autoLink="phone"  
  10.           />  

访问web网页:

  1. <TextView android:id="@+id/textView1"  
  2.           android:layout_width="fill_parent"  
  3.           android:layout_height="wrap_content"   
  4.           android:textColor="#FF0000"  
  5.           android:textSize="18dip"  
  6.           android:background="#00FF00"  
  7.           android:text="雨松MOMO的博客:http://blog.csdn.net/xys289187120"   
  8.           android:gravity="center_vertical|center_horizontal"  
  9.           android:autoLink="web"  
  10.           />  

发送邮件:

首选须要设置自己的电子邮件 否则Android是不知道你从那里发的邮件

  1. <TextView android:id="@+id/textView2"  
  2.           android:layout_width="fill_parent"  
  3.           android:layout_height="wrap_content"   
  4.           android:textColor="#FF0000"  
  5.           android:textSize="18dip"  
  6.           android:background="#FFFF00"  
  7.           android:text="发送邮件:xuanyusong@gmail.com"   
  8.           android:gravity="center_vertical|center_horizontal"  
  9.           android:autoLink="email"  
  10.           />  
  • 1
  • 2
  • 3
  • 下一页

相关内容