Android-超级链接不可点击 [英] Android - Hyperlink is not clickable

查看:67
本文介绍了Android-超级链接不可点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中有一些链接.一个用于网站,一个用于电话,一个用于电子邮件.电子邮件和电话链接都可以使用并且可以单击,但是由于某些原因,网站超链接仍然无法单击.有什么想法吗?下面的代码.

I have a few links in my application. One for a website, one for a phone number, and one for an email. The email and phone links are both working and clickable, however the website hyperlink is still not clickable for some reason. Any thoughts? Code below.

<string name="website" ><a href="http://www.XXXXXX.com">XXXXXX Website</a></string>
<string name="email" >sales@XXXXXXX.com</string>
<string name="phone" >P: XXX.XXX.XXXX</string>
<string name="fax" >F: XXX.XXX.XXXX</string>

上面是我的字符串,下面是显示它们的xml文件:

Above are my strings, and below is the xml file that displays them:

<TextView android:id="@+id/website"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_below="@id/imageButtonTwitter"
          android:gravity="center_horizontal"
          android:padding="10dp"
          android:autoLink="web"
          android:clickable="true"
          android:linksClickable="true"
          android:text="@string/website" />

<TextView android:id="@+id/email"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_below="@id/website"
          android:gravity="center_horizontal"
          android:padding="10dp"
          android:autoLink="email"
          android:linksClickable="true"
          android:text="@string/email" />

<TextView android:id="@+id/phone"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_below="@id/email"
          android:gravity="center_horizontal"
          android:padding="10dp"
          android:autoLink="phone"
          android:linksClickable="true"
          android:text="@string/phone" />

<TextView android:id="@+id/fax"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_below="@id/phone"
          android:gravity="center_horizontal"
          android:padding="10dp"
          android:text="@string/fax" />

就像我说的..其他的都是可点击的并且可以正常工作.我已经在两个模拟器以及我的Galaxy S4上进行了测试.有什么想法为什么该网站不可点击?

Like I said.. the others are clickable and working. I've tested it on two emulators, as well as my Galaxy S4. Any thoughts why the website is not clickable?

推荐答案

您需要在textview上调用它:

You need to call this on your textview:

TextView tv = (TextView) findViewById(R.id. website);
tv.setMovementMethod(LinkMovementMethod.getInstance());

您需要从TextView中删除:

You need to remove from your TextView:

android:autoLink="web"
android:clickable="true"
android:linksClickable="true"

这篇关于Android-超级链接不可点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆