0
我在嘗試附加一個TextView鏈接。但我似乎無法讓它工作。android設置文本鏈接查看
這裏是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" />
而這裏的setLink()方法
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));
}
我已經試過
How do I make links in a TextView clickable?
I want text view as a clickable link
所有3都經過高度評價,並沒有爲我工作。這導致我相信我做錯了什麼。
這裏有什麼問題嗎?或者可能有一些提示?
有一點需要補充,我需要能夠在方法中設置鏈接,因爲我們的實時和調試環境不同。 (不同域名)
如果可能的話,請查看我的答案https://stackoverflow.com/a/45727769/5381331這裏 –
嘗試這種在TextView的XML:機器人:自動鏈接= 「網絡」 –