2014.11.24
1:ClipData类:用于表示剪切的数据,此剪切的数据可以是复杂类型,包括一个或多个条目实例
(1)基础知识
>公共类:public class
>嵌套类:ClipData.Item(用于描述剪切数据的一个条目)
>继承常量:来自接口android.os.Parcelable
>继承方法:来自类java.lang.Object;来自接口android.os.Parcelable
>域:public static final Creator<ClipData>
>公共构造函数:ClipData(CharSequence label, String[] mimeTypes, ClipData.Item item)
ClipData(ClipDescription description, ClipData.Item item)
>public 方法:
void |
addItem(
ClipData.Item item)
Add a new Item to the overall ClipData container.
|
int |
describeContents()
Describe the kinds of special objects contained in this Parcelable's marshalled representation.
|
ClipDescription |
getDescription()
Return the
ClipDescription associated with this data, describing what it contains.
|
ClipData.Item |
getItemAt(int index)
Return a single item inside of the clip data.
|
int |
getItemCount()
Return the number of items in the clip data.
|
static ClipData |
newHtmlText(
CharSequence label,
CharSequence text,
String htmlText)
Create a new ClipData holding data of the type
MIMETYPE_TEXT_HTML .
|
static ClipData |
newIntent(
CharSequence label,
Intent intent)
Create a new ClipData holding an Intent with MIME type
MIMETYPE_TEXT_INTENT .
|
static ClipData |
newPlainText(
CharSequence label,
CharSequence text)
Create a new ClipData holding data of the type
MIMETYPE_TEXT_PLAIN .
|
static ClipData |
newRawUri(
CharSequence label,
Uri uri)
Create a new ClipData holding an URI with MIME type
MIMETYPE_TEXT_URILIST .
|
static ClipData |
newUri(
ContentResolver resolver,
CharSequence label,
Uri uri)
Create a new ClipData holding a URI.
|
String |
toString()
Returns a string containing a concise, human-readable description of this object.
|
void |
writeToParcel(
Parcel dest, int flags)
Flatten this object in to a Parcel.
|
总结:ClipData代表剪贴板中剪切数据。它有一个或多个Item实例,每个可容纳一个或多个数据项。 ClipData包含ClipDescription,用来描述剪贴内容的重要元数据。尤其是getDescription().getMimeType(INT)必须返回正确的MIME类型。为了正确的设置剪贴内容的MIME类型,建议使用newPlainText(CharSequence,CharSequence的),newUri(ContentResolver,CharSequence中,URI),newIntent(CharSequence, Intent)构造ClipData。每个Item的实例可以是三大数据类型之一:text,intent,URI。
(2):粘贴和复制数据
当数据类型复杂或者不一致时,复制和粘贴数据过程中要对数据类型进行转换,参见:http://sourcollection.diandian.com/post/2012-06-08/40028020578
2:ClipBoardManager类
(1)基础知识:
file:///F:/Android/SDK/docs/reference/android/content/ClipboardManager.html