5

I'm trying to use Linkify with a custom pattern which is supposed to match phone numbers which are either 10 or 11 digits long. I've written the following code -

Pattern japPhoneNoPattern = Pattern.compile("[0-9]{10,11}");
Linkify.addLinks(viewHolder.right_message, japPhoneNoPattern, "");

But it's not converting the text to link. Any idea what wrong I might be doing ?

In case it matters, I'm using linkify inside a ListView.

omerjerk
  • 4,090
  • 5
  • 40
  • 57

1 Answers1

0

XML

  <TextView
        android:id="@+id/test_phone_number"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="12345678910"/>

Code

    TextView t4 = (TextView)findViewById(R.id.test_phone_number);
    Linkify.addLinks(t4,Linkify.PHONE_NUMBERS);
Omer Malik
  • 409
  • 7
  • 15