I am using Xamarin and am trying to get the autolink working for a TextView.
Here is my code:
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
namespace TestTextViewAutoLink
{
[Activity (Label = "TestTextViewAutoLink", MainLauncher = true)]
public class MainActivity : Activity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
TextView textView = new TextView (this.ApplicationContext);
textView.AutoLinkMask = Android.Text.Util.MatchOptions.PhoneNumbers;
textView.Text = "This is a phone number 0800 32 32 32";
SetContentView(textView);
}
}
}
The text is being displayed, however the following error occurs when I click on the text:
Unfortunately, TestTextViewAutoLink has stopped
May I please have some help to get this working?
Thanks in advance.
EDIT
I have also tried this code, however the same error occurs:
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
TextView textView = new TextView (this.ApplicationContext);
//textView.AutoLinkMask = Android.Text.Util.MatchOptions.PhoneNumbers;
textView.Text = "This is a phone number 0800 32 32 32";
Linkify.AddLinks(textView, MatchOptions.PhoneNumbers);
SetContentView(textView);
}