在C#Android应用程序中设置TextView内部的超链接
我是初学者。我想向TextView添加超链接,如下所示: 一些文本[超链接]一些文本在C#Android应用程序中设置TextView内部的超链接,c#,android,xamarin,C#,Android,Xamarin,我是初学者。我想向TextView添加超链接,如下所示: 一些文本[超链接]一些文本 <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" an
<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中删除
自动链接
属性
<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;
TextView TextView=FindViewById(Resource.Id.TextView);
textView.TextFormatted=Html.FromHtml(“请阅读我们的”+
" " +
“在使用应用程序之前。”);
textView.MovementMethod=LinkMovementMethod.Instance;
我希望文本与实际URL不同,可能存在重复。现在不推荐使用此选项!现在,您必须在FromHtml方法中添加FromHtmlOptions枚举,以避免被弃用,例如:textView.TextFormatted=Html.FromHtml(“请在使用应用程序之前阅读我们的“+”\”>规则和条件“+”,FromHtmlOptions.ModeLegacy);