TextView that is linkified and selectable?

pixel picture pixel · Feb 13, 2013 · Viewed 8.3k times · Source

I would like to have a TextView that is both selectable and linkified. When I do both I end up with selectable text but links can't be clicked.

EDIT:

I'll show the code to explain with what I struggle:

    TextView textView = view.findViewById(R.id.mytext);
    textView.setText("My text: +4412345678 Go to website: www.google.com Blah blah");
    Linkify.addLinks(textView, Linkify.ALL);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        textView.setTextIsSelectable(true);
    }

Answer

JJ86 picture JJ86 · Feb 19, 2013

Did you try to add this on your TextView xml code?

    <TextView
    ...
    android:autoLink="all"
    android:textIsSelectable="true" />

I've tried it on my code and i can make a call/surf on web/mail and also select all text.