Android TextView实现带链接文字事件监听的三种常用方式示例

  

本文实例讲述了Android TextView实现带链接文字事件监听的三种常用方式。分享给大家供大家参考,具体如下:

     /* *   * TextView实现文字链接跳转功能   * @description:   * @author ldm   * @date 2016-4-21下午4:34:05   */公开课TextViewLinkAct延伸活动{   私人TextView tv_3;   私人TextView tv_4;   @Override   保护空白>   & lt; & # 63; xml version=" 1.0 " encoding=" utf - 8 " & # 63;比;   & lt; ScrollView xmlns: android=" http://schemas.android.com/apk/res/android "   android: layout_width=" match_parent "   android: layout_height=皐rap_content”比;   LinearLayout & lt;   android: layout_width=" match_parent "   android: layout_height=" wrap_content "   android:分频器=" & # 63;android: attr/listDivider”   android:取向=按怪薄?   android: showDividers=爸屑洹北?   & lt; !——通过在布局中autoLink属性设置TextView的链接功能。——比;   & lt; TextView   android: id=癅 + id/text1”   android: layout_width=" match_parent "   android: layout_height=" match_parent "   android: autoLink="所有"   android: paddingBottom=" 8 dp "   android:文本=",lt; b> text1:各种   的数据将auto-linked。amp;肝移植;/b>在   本文是一些可行的事情。例如,   你可以点击/比;   & lt; TextView   android: id=癅 + id/text3”   android: layout_width=" match_parent "   android: layout_height=" match_parent "   android: paddingBottom=" 8 dp "   android: paddingTop=" 8 dp "   android: textAppearance=" & # 63; android: attr/textAppearanceMedium”/比;   & lt; TextView   android: id=癅 + id/text4”   android: layout_width=" match_parent "   android: layout_height=" match_parent "   android: paddingTop=" 8 dp "   android: textAppearance=" & # 63; android: attr/textAppearanceMedium”/比;   & lt;/LinearLayout>   & lt;/ScrollView>      之前      

其中通过在而已代码中android: autoLink属性的选项目有:没有(无链接效果),网络(网页链接),电子邮件(发邮件),电话(打电话),地图(定位)及所有(默认全都自动链接)。

  

更多关于Android相关内容感兴趣的读者可查看本站专题:《Android开发入门与进阶教程》、《Android调试技巧与常见问题解决方法汇总》、《Android基本组件用法总结》,《Android视图视图技巧总结》,《Android布局布局技巧总结》及《安卓控件用法总结》

  

希望本文所述对大家Android程序设计有所帮助。

Android TextView实现带链接文字事件监听的三种常用方式示例