LinkifyCompat
public final class LinkifyCompat
LinkifyCompat brings in Linkify improvements for URLs and email addresses to older API levels.
Summary
Public methods |
|
|---|---|
static boolean |
Scans the text of the provided Spannable and turns all occurrences of the link types indicated in the mask into clickable links. |
static boolean |
Scans the text of the provided TextView and turns all occurrences of the link types indicated in the mask into clickable links. |
static boolean |
Applies a regex to a Spannable turning the matches into links. |
static void |
Applies a regex to the text of a TextView turning the matches into links. |
static boolean |
addLinks(Applies a regex to a Spannable turning the matches into links. |
static void |
addLinks(Applies a regex to the text of a TextView turning the matches into links. |
static boolean |
addLinks(Applies a regex to a Spannable turning the matches into links. |
static void |
addLinks(Applies a regex to the text of a TextView turning the matches into links. |
Public methods
addLinks
public static boolean addLinks(@NonNull Spannable text, int mask)
Scans the text of the provided Spannable and turns all occurrences of the link types indicated in the mask into clickable links. If the mask is nonzero, it also removes any existing URLSpans attached to the Spannable, to avoid problems if you call it repeatedly on the same text.
| Parameters | |
|---|---|
@NonNull Spannable text |
Spannable whose text is to be marked-up with links |
int mask |
Mask to define which kinds of links will be searched. |
| Returns | |
|---|---|
boolean |
True if at least one link is found and applied. |
addLinks
public static boolean addLinks(@NonNull TextView text, int mask)
Scans the text of the provided TextView and turns all occurrences of the link types indicated in the mask into clickable links. If matches are found the movement method for the TextView is set to LinkMovementMethod.
| Parameters | |
|---|---|
@NonNull TextView text |
TextView whose text is to be marked-up with links |
int mask |
Mask to define which kinds of links will be searched. |
| Returns | |
|---|---|
boolean |
True if at least one link is found and applied. |
addLinks
public static boolean addLinks(
@NonNull Spannable text,
@NonNull Pattern pattern,
@Nullable String scheme
)
Applies a regex to a Spannable turning the matches into links.
addLinks
public static void addLinks(
@NonNull TextView text,
@NonNull Pattern pattern,
@Nullable String scheme
)
Applies a regex to the text of a TextView turning the matches into links. If links are found then UrlSpans are applied to the link text match areas, and the movement method for the text is changed to LinkMovementMethod.
addLinks
public static boolean addLinks(
@NonNull Spannable spannable,
@NonNull Pattern pattern,
@Nullable String scheme,
@Nullable Linkify.MatchFilter matchFilter,
@Nullable Linkify.TransformFilter transformFilter
)
Applies a regex to a Spannable turning the matches into links.
| Parameters | |
|---|---|
@NonNull Spannable spannable |
Spannable whose text is to be marked-up with links |
@NonNull Pattern pattern |
Regex pattern to be used for finding links |
@Nullable String scheme |
URL scheme string (eg |
@Nullable Linkify.MatchFilter matchFilter |
The filter that is used to allow the client code additional control over which pattern matches are to be converted into links. |
@Nullable Linkify.TransformFilter transformFilter |
Filter to allow the client code to update the link found. |
| Returns | |
|---|---|
boolean |
True if at least one link is found and applied. |
addLinks
public static void addLinks(
@NonNull TextView text,
@NonNull Pattern pattern,
@Nullable String scheme,
@Nullable Linkify.MatchFilter matchFilter,
@Nullable Linkify.TransformFilter transformFilter
)
Applies a regex to the text of a TextView turning the matches into links. If links are found then UrlSpans are applied to the link text match areas, and the movement method for the text is changed to LinkMovementMethod.
| Parameters | |
|---|---|
@NonNull TextView text |
TextView whose text is to be marked-up with links |
@NonNull Pattern pattern |
Regex pattern to be used for finding links |
@Nullable String scheme |
URL scheme string (eg |
@Nullable Linkify.MatchFilter matchFilter |
The filter that is used to allow the client code additional control over which pattern matches are to be converted into links. |
@Nullable Linkify.TransformFilter transformFilter |
Filter to allow the client code to update the link found. |
addLinks
public static boolean addLinks(
@NonNull Spannable spannable,
@NonNull Pattern pattern,
@Nullable String defaultScheme,
@Nullable String[] schemes,
@Nullable Linkify.MatchFilter matchFilter,
@Nullable Linkify.TransformFilter transformFilter
)
Applies a regex to a Spannable turning the matches into links.
| Parameters | |
|---|---|
@NonNull Spannable spannable |
Spannable whose text is to be marked-up with links. |
@NonNull Pattern pattern |
Regex pattern to be used for finding links. |
@Nullable String defaultScheme |
The default scheme to be prepended to links if the link does not start with one of the |
@Nullable String[] schemes |
Array of schemes (eg |
@Nullable Linkify.MatchFilter matchFilter |
The filter that is used to allow the client code additional control over which pattern matches are to be converted into links. |
@Nullable Linkify.TransformFilter transformFilter |
Filter to allow the client code to update the link found. |
| Returns | |
|---|---|
boolean |
True if at least one link is found and applied. |
addLinks
public static void addLinks(
@NonNull TextView text,
@NonNull Pattern pattern,
@Nullable String defaultScheme,
@Nullable String[] schemes,
@Nullable Linkify.MatchFilter matchFilter,
@Nullable Linkify.TransformFilter transformFilter
)
Applies a regex to the text of a TextView turning the matches into links. If links are found then UrlSpans are applied to the link text match areas, and the movement method for the text is changed to LinkMovementMethod.
| Parameters | |
|---|---|
@NonNull TextView text |
TextView whose text is to be marked-up with links. |
@NonNull Pattern pattern |
Regex pattern to be used for finding links. |
@Nullable String defaultScheme |
The default scheme to be prepended to links if the link does not start with one of the |
@Nullable String[] schemes |
Array of schemes (eg |
@Nullable Linkify.MatchFilter matchFilter |
The filter that is used to allow the client code additional control over which pattern matches are to be converted into links. |
@Nullable Linkify.TransformFilter transformFilter |
Filter to allow the client code to update the link found. |