在 TextView 中声明自动链接会隐藏文本...!

Declaring autolink in TextView hides the text...!

我正在尝试为 TextView 定义 autolink = "web"。令人惊讶的是,当我声明这一点时,TextView 中的文本会隐藏起来,并且仅在第一次单击时才可见。这太令人惊讶了,我在我的应用程序的许多部分都具有相同的功能,而且运行良好。这是我唯一找不到问题所在的地方。

请帮我解决一下:

这是我的 TextView XML 代码:

<TextView
            android:id="@+id/details_webAddress_textView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/details_location_textView"
            android:drawableLeft="@drawable/icon_website_earth"
            android:drawablePadding="5dp"
            android:gravity="center"
            android:padding="5dp"
            android:singleLine="true"
            android:autoLink="web"
            android:text="www.google.com"
            android:visibility="visible" />

以下是自动链接运行良好的 TextView:

<TextView
                android:id="@+id/websiteAddress_textView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:autoLink="web"
                android:padding="5dp"
                android:singleLine="true"
                android:text="www.whosebug.com" />

尝试使用:

TextView textLink = (TextView) findViewById(R.id.details_webAddress_textView);
textLink.setVisibility(View.INVISIBLE);
Button buttonDetails = (Button) findViewById(R.id.button);

buttonDetails.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                textLink.setVisibility(View.VISIBLE); // text visible on firt click
                String url = "http://www.example.com";
                Intent i = new Intent(Intent.ACTION_VIEW);
                i.setData(Uri.parse(url));
                startActivity(i); // open link with default browser
            }
        });

除 "android:autoLink" 属性外,还需要在 xml 中设置 "android:textColorLink" 属性。

<TextView
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:autoLink="web"
     android:textColorLink="@color/yourDesiredLinkColor"/>