Sdílet prostřednictvím


ClipData Class

Definition

Representation of a clipped data on the clipboard.

[Android.Runtime.Register("android/content/ClipData", DoNotGenerateAcw=true)]
public class ClipData : Java.Lang.Object, Android.OS.IParcelable, IDisposable, Java.Interop.IJavaPeerable
[<Android.Runtime.Register("android/content/ClipData", DoNotGenerateAcw=true)>]
type ClipData = class
    inherit Object
    interface IParcelable
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
Inheritance
ClipData
Attributes
Implements

Remarks

Representation of a clipped data on the clipboard.

ClipData is a complex type containing one or more Item instances, each of which can hold one or more representations of an item of data. For display to the user, it also has a label.

A ClipData contains a ClipDescription, which describes important meta-data about the clip. In particular, its ClipDescription#getMimeType(int) getDescription().getMimeType(int) must return correct MIME type(s) describing the data in the clip. For help in correctly constructing a clip with the correct MIME type, use #newPlainText(CharSequence, CharSequence), #newUri(ContentResolver, CharSequence, Uri), and #newIntent(CharSequence, Intent).

Each Item instance can be one of three main classes of data: a simple CharSequence of text, a single Intent object, or a Uri. See Item for more details.

<div class="special reference"> <h3>Developer Guides</h3>

For more information about using the clipboard framework, read the Copy and Paste developer guide.

</div>

"ImplementingPaste"><h3>Implementing Paste or Drop</h3>

To implement a paste or drop of a ClipData object into an application, the application must correctly interpret the data for its use. If the Item it contains is simple text or an Intent, there is little to be done: text can only be interpreted as text, and an Intent will typically be used for creating shortcuts (such as placing icons on the home screen) or other actions.

If all you want is the textual representation of the clipped data, you can use the convenience method Item#coerceToText Item.coerceToText. In this case there is generally no need to worry about the MIME types reported by ClipDescription#getMimeType(int) getDescription().getMimeType(int), since any clip item can always be converted to a string.

More complicated exchanges will be done through URIs, in particular "content:" URIs. A content URI allows the recipient of a ClipData item to interact closely with the ContentProvider holding the data in order to negotiate the transfer of that data. The clip must also be filled in with the available MIME types; #newUri(ContentResolver, CharSequence, Uri) will take care of correctly doing this.

For example, here is the paste function of a simple NotePad application. When retrieving the data from the clipboard, it can do either two things: if the clipboard contains a URI reference to an existing note, it copies the entire structure of the note into a new note; otherwise, it simply coerces the clip into text and uses that as the new note's contents.

{

Java documentation for android.content.ClipData.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

ClipData(ClipData)

Create a new clip that is a copy of another clip.

ClipData(ClipDescription, ClipData+Item)

Create a new clip that is a copy of another clip.

ClipData(ICharSequence, String[], ClipData+Item)

Create a new clip that is a copy of another clip.

ClipData(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

ClipData(String, String[], ClipData+Item)

Create a new clip.

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
Creator
Description

Return the ClipDescription associated with this data, describing what it contains.

Handle

The handle to the underlying Android instance.

(Inherited from Object)
ItemCount

Return the number of items in the clip data.

JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Methods

AddItem(ClipData+Item)

Add a new Item to the overall ClipData container.

AddItem(ContentResolver, ClipData+Item)

Add a new Item to the overall ClipData container.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
DescribeContents()

Describe the kinds of special objects contained in this Parcelable's marshalled representation.

Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetItemAt(Int32)

Return a single item inside of the clip data.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
NewHtmlText(ICharSequence, ICharSequence, String)

Create a new ClipData holding data of the type ClipDescription#MIMETYPE_TEXT_HTML.

NewHtmlText(String, String, String)

Create a new ClipData holding data of the type ClipDescription#MIMETYPE_TEXT_HTML.

NewIntent(ICharSequence, Intent)

Create a new ClipData holding an Intent with MIME type ClipDescription#MIMETYPE_TEXT_INTENT.

NewIntent(String, Intent)

Create a new ClipData holding an Intent with MIME type ClipDescription#MIMETYPE_TEXT_INTENT.

NewPlainText(ICharSequence, ICharSequence)

Create a new ClipData holding data of the type ClipDescription#MIMETYPE_TEXT_PLAIN.

NewPlainText(String, String)

Create a new ClipData holding data of the type ClipDescription#MIMETYPE_TEXT_PLAIN.

NewRawUri(ICharSequence, Uri)

Create a new ClipData holding an URI with MIME type ClipDescription#MIMETYPE_TEXT_URILIST.

NewRawUri(String, Uri)

Create a new ClipData holding an URI with MIME type ClipDescription#MIMETYPE_TEXT_URILIST.

NewUri(ContentResolver, ICharSequence, Uri)

Create a new ClipData holding a URI.

NewUri(ContentResolver, String, Uri)

Create a new ClipData holding a URI.

Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
WriteToParcel(Parcel, ParcelableWriteFlags)

Flatten this object in to a Parcel.

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to