Class URLSpan

All Implemented Interfaces:
ParcelableSpan, UpdateAppearance, Parcelable

public class URLSpan extends ClickableSpan implements ParcelableSpan
Implementation of the ClickableSpan that allows setting a url string. When selecting and clicking on the text to which the span is attached, the URLSpan will try to open the url, by calling Core.openURI(String).

For example, a URLSpan can be used like this:

 SpannableString string = new SpannableString("Text with a url span");
 string.setSpan(new URLSpan("https://google.com"), 12, 15, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
 
Text with URLSpan.
  • Constructor Details

    • URLSpan

      public URLSpan(String url)
      Constructs a URLSpan from an url string.
      Parameters:
      url - the url string
    • URLSpan

      public URLSpan(@NonNull Parcel src)
      Constructs a URLSpan from a parcel.
  • Method Details

    • getSpanTypeId

      public int getSpanTypeId()
      Description copied from interface: ParcelableSpan
      Return a special type identifier for this span class.
      Specified by:
      getSpanTypeId in interface ParcelableSpan
    • writeToParcel

      public void writeToParcel(@NonNull Parcel dest, int flags)
      Description copied from interface: Parcelable
      The subclass implements the method to flatten its contents by calling the methods of Parcel for its primitive values.
      Specified by:
      writeToParcel in interface Parcelable
      Parameters:
      dest - the parcel to write the object's data to
      flags - the flags about how the object should be written
    • getURL

      public String getURL()
      Get the url string for this span.
      Returns:
      the url string.
    • onClick

      public void onClick(@NonNull View widget)
      Description copied from class: ClickableSpan
      Performs the click action associated with this span.
      Specified by:
      onClick in class ClickableSpan