Android textview with clickable phone number [closed]

穿精又带淫゛_ 提交于 2019-12-10 00:32:50

问题


I have a textview showing Phone: 0900-1111, Fax: 0900-2222

Is there a way to make the phone clickable but not the fax.

Using

Phone: <a href="tel:09001111">0900-1111</a>, Fax: 0900-2222

With autolink set to phone, both are clickable !


回答1:


have you checked the API demos ?

They have a sample just for this , under Views/Text/Linkify.

The class is located at com.example.android.apis.text.Link.java

for example , the string used there for one of the textView is :

<string name="link_text_manual"><b>text2: Explicit links using &lt;a&gt; markup.</b>
  This has markup for a <a href="http://www.google.com">link</a> specified
  via an &lt;a&gt; tag.  Use a \"tel:\" URL
  to <a href="tel:4155551212">dial a phone number</a>.
</string>

and the textView is :

  <TextView android:id="@+id/text2"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:paddingTop="8dp"
            android:paddingBottom="8dp"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:text="@string/link_text_manual"
            />


来源:https://stackoverflow.com/questions/14762956/android-textview-with-clickable-phone-number

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!