Link not work with custom template

I am trying to use Linkify with a custom template that should match phone numbers 10 or 11 digits long. I wrote the following code -

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

But this is not a conversion of text into a link. Any idea what I can do wrong?

In case that matters, I use the link inside the ListView.

+4
source share
1 answer

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"/>

the code

    TextView t4 = (TextView)findViewById(R.id.test_phone_number);
    Linkify.addLinks(t4,Linkify.PHONE_NUMBERS);
0
source

Source: https://habr.com/ru/post/1629162/


All Articles