为什么TextView
超链接无法使用。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'内容来处理。 – CommonsWare 2012-07-10 12:37:43