URLSpan
public
class
URLSpan
extends ClickableSpan
implements
ParcelableSpan
java.lang.Object | |||
↳ | android.text.style.CharacterStyle | ||
↳ | android.text.style.ClickableSpan | ||
↳ | android.text.style.URLSpan |
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 launching an an Activity with an Intent.ACTION_VIEW
intent.
For example, a URLSpan
can be used like this:
SpannableString string = new SpannableString("Text with a url span"); string.setSpan(new URLSpan("http://www.developer.android.com"), 12, 15, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
URLSpan
.Summary
Inherited constants |
---|
Public constructors | |
---|---|
URLSpan(Parcel src)
Constructs a |
|
URLSpan(String url)
Constructs a |
Public methods | |
---|---|
int
|
describeContents()
Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
int
|
getSpanTypeId()
Return a special type identifier for this span class. |
String
|
getURL()
Get the url string for this span. |
void
|
onClick(View widget)
Performs the click action associated with this span. |
String
|
toString()
Returns a string representation of the object. |
void
|
writeToParcel(Parcel dest, int flags)
Flatten this object in to a Parcel. |
Inherited methods | |
---|---|
Public constructors
URLSpan
public URLSpan (Parcel src)
Constructs a URLSpan
from a parcel.
Parameters | |
---|---|
src |
Parcel : This value cannot be null . |
URLSpan
public URLSpan (String url)
Constructs a URLSpan
from a url string.
Parameters | |
---|---|
url |
String : the url string |
Public methods
describeContents
public int describeContents ()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation. For example, if the object will
include a file descriptor in the output of writeToParcel(android.os.Parcel, int)
,
the return value of this method must include the
CONTENTS_FILE_DESCRIPTOR
bit.
Returns | |
---|---|
int |
a bitmask indicating the set of special object types marshaled
by this Parcelable object instance.
Value is either 0 or CONTENTS_FILE_DESCRIPTOR |
getSpanTypeId
public int getSpanTypeId ()
Return a special type identifier for this span class.
Returns | |
---|---|
int |
getURL
public String getURL ()
Get the url string for this span.
Returns | |
---|---|
String |
the url string. |
onClick
public void onClick (View widget)
Performs the click action associated with this span.
Parameters | |
---|---|
widget |
View : This value cannot be null . |
toString
public String toString ()
Returns a string representation of the object.
Returns | |
---|---|
String |
a string representation of the object. |
writeToParcel
public void writeToParcel (Parcel dest, int flags)
Flatten this object in to a Parcel.
Parameters | |
---|---|
dest |
Parcel : This value cannot be null . |
flags |
int : Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE .
Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE , and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES |