Can't create hyperlink labels in Android

AdrianKnightAdrianKnight USMember ✭✭✭✭

I'm trying to customize a Label such that it auto detects URLs and other things and creates clickable regions:

        protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.Label> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null || Element == null)
            {
                return;
            }

            Control.AutoLinkMask = Android.Text.Util.MatchOptions.All;
            Control.LinksClickable = true;
        }

http://stackoverflow.com/questions/18222433/how-to-make-normal-links-in-textview-clickable

            new CustomLabel
            {
                 Text = "Test hyperlink: <a href=\"http://www.google.com\">Google</a>"
            }

            new CustomLabel
            {
                 Text = "Test hyperlink: http://www.google.com"
            }

do not work :( Any idea why?

P.S. I don't want to simply add a tap gesture to the entire label. I want certain parts to be clickable.

Answers

  • JamesRussoJamesRusso USMember

    @AdrianKnight can you post your entire Renderer?

    I'm betting on the Renderer is registered to Xamarin.Forms.Label, not "CustomLabel" (At least from the short snippet above).

Sign In or Register to comment.