如何TextView的超链接在C#中的Andr​​oid? [英] How to hyperlink TextView in C# android?

查看:128
本文介绍了如何TextView的超链接在C#中的Andr​​oid?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示一些文字,点击后会重定向我到一个网站。我用C#(Xamarian工作室)Android应用程序编写。

I would like to display a some text that when clicked will redirect me to a website. I am writing by android app with C# (Xamarian studio).

<TextView
        android:id="@+id/rsstitle"
        android:autoLink="web"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#FF7F3300"
        android:textSize="16dip"
        android:textStyle="bold" />

view.FindViewById<TextView> (Resource.Id.rsstitle).Text = values [position];
//values[position] contains a title string eg "Google"

链接[位置]包含一个URI,如 https://www.google.co.nz/

我怎么让这个谷歌的显示,但点击后引导到的https:// WWW。 google.co.nz/

How do I make it so that "Google" is displayed but when clicked directs to https://www.google.co.nz/

推荐答案

发现我的解决方案:

String linkText = "<a href=\"" + RSSActivity.links [position] + "\">" + values [position] + "</a> ";

link.TextFormatted = Html.FromHtml(linkText);
link.MovementMethod = LinkMovementMethod.Instance;

这篇关于如何TextView的超链接在C#中的Andr​​oid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆