Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Linkify text in Android Textview

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 284
    Comment on it

    Linkify is very helpful to create links from TextView or Spannable. Linkify get Regular expression and work on Text with Regular expression.


     For example, you have a random text which includes web URLs also and you want to use web URL as clickable only the Linkify is very helpful for that.

    You can set linkify from XML code of TextView.

        <TextView
            android:id="@+id/tv"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:autoLink="web"
            android:text="https://www.findnerd.com" />

     

    or you can set programmatically also.

    Linkify.addLinks(textview, Linkify.WEB_URLS);

    Linkify will check links of:-

    1. Phone number,

    2. Email address.

    3. Web Address.

    4. All Of above.

     

    Linkify start application according to the type of link. Suppose if the link is the web then open the browser. If the link is email then open an Email application.

     

    Happy Coding :D

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: