爲什麼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