Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/312.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在C#Android应用程序中设置TextView内部的超链接_C#_Android_Xamarin - Fatal编程技术网

在C#Android应用程序中设置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添加超链接,如下所示: 一些文本[超链接]一些文本

<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);