hyperlink - 在 android 中使用 LinkMovementMethod 运行一个简单的链接
问题描述
如何使用以下命令运行简单链接?
<TextView
android:text="text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView1" />
TextView textView = FindViewById<TextView>(Resource.Id.textView1);
textView.TextFormatted = Android.Text.Html.FromHtml("https://www.google.com");
textView.MovementMethod = Android.Text.Method.LinkMovementMethod.Instance;
这些工作:
textView.TextFormatted = Android.Text.Html.FromHtml("<a href=\"" + "https://www.google.com" + "\">google</a>");
textView.TextFormatted = Android.Text.Html.FromHtml("<a href=\"" + "https://www.google.com" + "\">https://www.google.com</a>");
这也不起作用:
<TextView
android:text="text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:id="@+id/textView1" />
textView.TextFormatted = Android.Text.Html.FromHtml("<u>" + "https://www.google.com" + "</u>");
解决方案
推荐阅读
- python - for循环计数器,报告1
- image - 使用放大存储将图像错误上传到 s3 (React Native - Expo - Amplify)
- python - 如何在代码中使用一维数组,这些数组是使用 python 中不同 IDLE 文件中的代码生成的?
- ssis - SSIS FTP 不会发送文件
- d3.js - D3:将工具提示定位在圆环图之外
- .net - .netstandard 2.0 中 AppDomain.CurrentDomain.SetupInformation.PrivateBinPath 的替代方法是什么
- c# - 如何在 c# 的嵌套循环中为特定数据对象添加元素?
- asp.net-mvc - User.Identity.GetUserId() 在我的所有控制器上返回 null
- c# - 如何使 listView 内容水平对齐?
- json - 从 ec2 创建寄存器中提取 volume_id