How to make linkable textview with generated link in a string in Android Xmarine c#

soumenhaldersoumenhalder ✭✭Member ✭✭

How to make linkable textview with generated link in a string in Android Xmarine c#. Here The String is dynamic, that means string will comes from database, it may change for every time. this string may contain a link in the string. Here I am giving some dynamic string with link. I need to make links in the string.

String Example:
1> "https://forums.xamarin.com"
2> "Hello we are using Xmarin, check https://docs.microsoft.com/en-gb/xamarin/"
3> "https://docs.microsoft.com/en-gb/xamarin/#pivot=platforms&panel=Android Xmarin is great"

Answers

  • DarshanJSDarshanJS ✭✭✭✭ USMember ✭✭✭✭
    edited August 2018

    @soumenhalder said:
    How to make linkable textview with generated link in a string in Android Xmarine c#. Here The String is dynamic, that means string will comes from database, it may change for every time. this string may contain a link in the string. Here I am giving some dynamic string with link. I need to make links in the string.

    String Example:
    1> "https://forums.xamarin.com"
    2> "Hello we are using Xmarin, check https://docs.microsoft.com/en-gb/xamarin/"
    3> "https://docs.microsoft.com/en-gb/xamarin/#pivot=platforms&panel=Android Xmarin is great"

    Hi,

    You can bind your dynamic values to label and use TapGestureRecognizer

    <Label  Text="{Binding yourvalue}"  HorizontalOptions="Center"   TextColor="#770754"  >
    
                                            <Label.GestureRecognizers>
                                                <TapGestureRecognizer
                                                Tapped="TapGestureRecognizer_Tapped"
                                                NumberOfTapsRequired="1" />
                                            </Label.GestureRecognizers>
                                        </Label>
    
    
        private void TapGestureRecognizer_Tapped(object sender, EventArgs e)
                {
                    if (website != null && website != "")
                    {
                        Device.OpenUri(new System.Uri(website));
                    }
                }
    
Sign In or Register to comment.