Reputation: 2457
I'm trying to attach a link to a TextView. But I can't seem to get it to work.
Here's the TextView
<TextView
android:id="@+id/terms"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:clickable="true"
android:linksClickable="true"
android:text="@string/terms" />
And here's the setLink() method
private void setLinks(){
String termsURI = "";
TextView termsTextView = (TextView) findViewById(R.id.terms);
String termsLink = "<a href='www.google.com'>terms test</a>";
termsTextView.setMovementMethod(LinkMovementMethod.getInstance());
termsTextView.setText(Html.fromHtml(termsLink));
}
I've tried
How do I make links in a TextView clickable?
I want text view as a clickable link
All 3 are highly reviewed and did not work for me. Which leads me to believe I'm doing something wrong.
Is there something wrong here? or possibly some tips?
One thing to add, I need to be able to set the link in a method, since our live and debug environment differ. (different domains)
Upvotes: 0
Views: 93
Reputation: 1168
Maybe you missed "http://" in the URL string.
Please try this one:
String termsLink = "<a href='http://www.google.com'>terms test</a>";
Upvotes: 1