【问题标题】:How to Handle link and number from plain text如何处理纯文本中的链接和数字
【发布时间】:2018-10-29 00:24:57
【问题描述】:

我下载用户数据,其中我有一个数字、电子邮件、网站和描述中的纯文本。我的第一个问题是如何在文本中找到这些链接和数字,识别和使用它们?费。当用户点击号码时,应用程序应打开新应用程序拨打电话。

示例描述文本:

Lorem ipsum dolor sit amet,+44 798-09-09 consectetur adipiscing elit,sed do eiusmod tempor incididunt ut www.google.com et dolore magna aliqua。 Ut enim ad minim veniam, quis address@gmail.com ullamco

【问题讨论】:

    标签: java android android-recyclerview plaintext


    【解决方案1】:

    为TextView 使用autoLink 属性。它会自动处理所有链接及其点击。

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="text"
        android:autoLink="phone" />
    

    您也可以使用autoLink="web" 或autoLink="all"。

    您可以从documentation 中查看autoLink 的所有可能值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-11
      • 2019-08-19
      • 1970-01-01
      • 1970-01-01
      • 2023-03-11
      • 2021-12-16
      • 2016-09-29
      • 2013-07-27
      相关资源
      最近更新 更多