0

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 !

Kara
  • 6,115
  • 16
  • 50
  • 57
user2052680
  • 131
  • 1
  • 6

1 Answers1

4

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"
            />
android developer
  • 114,585
  • 152
  • 739
  • 1,270
  • I use that but I have 2 links instead of only the one specified vie the anchor tag... – user2052680 Feb 08 '13 at 07:42
  • I don't understand. Could you please show what you want to have , and what you've tried to do ? The sample there has plenty of different links , all are customizable and can be turned on/off. – android developer Feb 08 '13 at 07:45
  • Phone: 0900-1111, Fax: 0900-2222 ... I want the fax number NOT clickable. I tried with or without href=tel, but they are always BOTH clickable. – user2052680 Feb 08 '13 at 08:41
  • 1
    Have you tried disabling the autolink , as i've written ? Have you tried the sample ? Please try , and then update your question , as it doesn't contain a code sample that shows that it doesn't work. – android developer Feb 08 '13 at 09:11
  • Thanks... Indeed I had to remove the autoLink to have the href working as defined in the string. – user2052680 Feb 11 '13 at 10:41
  • I had to enable `autolink` on the textview for the links to do something when clicking on them. – Zapnologica Nov 18 '14 at 21:05