在C#Android应用程序的TextView中设置超链接
本文关键字:设置 超链接 TextView C#Android 应用程序 | 更新日期: 2023-09-27 17:59:37
我是初学者。我想将超链接添加到TextView,如下所示:some_text[超链接]some_text。
<TextView
android:text="Please read our *rules and conditions* before using app."
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView"
android:textColor="#000000"
android:autoLink="web" />
您可以通过编程实现这一点。从TextView中删除autoLink
属性。
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
在你的活动课上,
TextView textView = FindViewById<TextView>(Resource.Id.textView);
textView.TextFormatted = Html.FromHtml("Please read our " +
"<a href='"http://www.xamarin.com'">Rules and Conditions</a> " +
"before using app.");
textView.MovementMethod = LinkMovementMethod.Instance;