我想文本视图作为一个可点击的链接我想、作为一个、视图、文本

2023-09-07 08:35:03 作者:阳光总照着我

<TextView
    android:id="@+id/link"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:text="Forget password?"
    android:autoLink="all"
    android:linksClickable="true"
    android:textColor="@color/lgreen"
    android:textStyle="italic"
     />

机器人是突出在TextView的链接,但它们不以点击响应。谁能告诉我,我该怎么办,作为一个可点击的,并移动到另一个链接。 我试图多次通过看实例。但我不能。有人能解释我清楚如何改变文本视图作为一个可点击的链接。

Android is highlighting the links in the TextView, but they do not respond to clicks. Can someone tell me how can i do that as a clickable and move to another link. i tried more times by seeing examples. but i can't. Can some one explain me clearly how to change text view as a clickable link.

推荐答案

所有测试和工作100% 下面是一个完整的例子 解决方案:机器人:自动链接=网络 示例XML

All tested and working 100% below is a complete example Solution: android:autoLink="web" Sample Xml

    <TextView
        android:id="@+id/txtLostpassword"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:autoLink="email"
        android:gravity="center"
        android:padding="20px"
        android:text="@string/lostpassword"
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <TextView
        android:id="@+id/txtLostpassword"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:autoLink="web"
        android:gravity="center"
        android:padding="20px"
        android:text="@string/defaultpassword"
        android:textAppearance="?android:attr/textAppearanceSmall" />

在string.xml

String in string.xml

<string name="lostpassword">If you lost your password please contact <a href="mailto:support@cleverfinger.com.au?Subject=Lost%20Password" target="_top">support@cleverfinger.com.au</a></string>

<string name="defaultpassword">User Guide <a href="http://www.cleverfinger.com.au/user-guide/">http://www.cleverfinger.com.au/user-guide/</a></string>