0

私は Xamarin を使用しており、TextView でオートリンクを機能させようとしています。

これが私のコードです:

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

テキストは表示されていますが、テキストをクリックすると次のエラーが発生します。

残念ながら、TestTextViewAutoLink は停止しました

これを機能させるために何か助けてもらえますか?

前もって感謝します。

編集

このコードも試しましたが、同じエラーが発生します。

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

0 に答える 0