【发布时间】:2012-07-09 22:23:25
【问题描述】:
为什么TextView 超链接不起作用。
在自定义dialog box 中使用超链接。
超链接不出现。
我哪里弄错了。怎么解决。给我指导。
XML 代码是
<TextView
android:id="@+id/google_Link"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:padding="10dip"
android:textSize="20dip"
android:linksClickable="true"
android:autoLink="all"
android:textColorLink="#306EFF"
android:text="" />
Android 代码是
TextView googleLink = ( TextView ) layout.findViewById( R.id.google_Link );
googleLink.setClickable(true);
googleLink.setMovementMethod(LinkMovementMethod.getInstance());
googleLink.setText( Html.fromHtml( "<a href=`http://www.google.co.in`>Google</a>" ) );
Android 清单代码是
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
提前致谢。
【问题讨论】:
-
反引号在 HTML 中不用于字符串分隔符。在 Java 中使用
\"在带引号的字符串中嵌入引号。我也会去掉setClickable()和setMovementMethod(),因为它们应该由你提议的TextView内容处理。
标签: android xml android-layout hyperlink