Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)
Android APIs
public final class

CompletionInfo

extends Object
implements Parcelable
java.lang.Object
   ↳ android.view.inputmethod.CompletionInfo

Class Overview

Information about a single text completion that an editor has reported to an input method.

This class encapsulates a completion offered by an application that wants it to be presented to the user by the IME. Usually, apps present their completions directly in a scrolling list for example (UI developers will usually use or extend to implement this). However, in some cases, the editor may not be visible, as in the case in extract mode where the IME has taken over the full screen. In this case, the editor can choose to send their completions to the IME for display.

Most applications who want to send completions to an IME should use AutoCompleteTextView as this class makes this process easy. In this case, the application would not have to deal directly with this class.

An application who implements its own editor and wants direct control over this would create an array of CompletionInfo objects, and send it to the IME using displayCompletions(View, CompletionInfo[]) . The IME would present the completions however they see fit, and call back to the editor through commitCompletion(CompletionInfo) . The application can then pick up the commit event by overriding onCommitCompletion(CompletionInfo) .

Summary

[Expand]
Inherited Constants
From interface android.os.Parcelable
Fields
public static final Creator < CompletionInfo > CREATOR Used to make this class parcelable.
Public Constructors
CompletionInfo (long id, int index, CharSequence text)
Create a simple completion with just text, no label.
CompletionInfo (long id, int index, CharSequence text, CharSequence label)
Create a full completion with both text and label.
Public Methods
int describeContents ()
Describe the kinds of special objects contained in this Parcelable's marshalled representation.
long getId ()
Return the abstract identifier for this completion, typically corresponding to the id associated with it in the original adapter.
CharSequence getLabel ()
Return the user-visible label for the completion, or null if the plain text should be shown.
int getPosition ()
Return the original position of this completion, typically corresponding to its position in the original adapter.
CharSequence getText ()
Return the actual text associated with this completion.
String toString ()
Returns a string containing a concise, human-readable description of this object.
void writeToParcel ( Parcel dest, int flags)
Used to package this object into a Parcel .
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.os.Parcelable

Fields

public static final Creator < CompletionInfo > CREATOR

Added in API level 3

Used to make this class parcelable.

Public Constructors

public CompletionInfo (long id, int index, CharSequence text)

Added in API level 3

Create a simple completion with just text, no label.

Parameters
id An id that get passed as is (to the editor's discretion)
index An index that get passed as is. Typically this is the index in the list of completions inside the editor.
text The text that should be inserted into the editor when this completion is chosen.

public CompletionInfo (long id, int index, CharSequence text, CharSequence label)

Added in API level 3

Create a full completion with both text and label. The text is what will get inserted into the editor, while the label is what the IME should display. If they are the same, use the version of the constructor without a `label' argument.

Parameters
id An id that get passed as is (to the editor's discretion)
index An index that get passed as is. Typically this is the index in the list of completions inside the editor.
text The text that should be inserted into the editor when this completion is chosen.
label The text that the IME should be showing among the completions list.

Public Methods

public int describeContents ()

Added in API level 3

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

Returns
  • a bitmask indicating the set of special object types marshalled by the Parcelable.

public long getId ()

Added in API level 3

Return the abstract identifier for this completion, typically corresponding to the id associated with it in the original adapter.

public CharSequence getLabel ()

Added in API level 3

Return the user-visible label for the completion, or null if the plain text should be shown. If non-null, this will be what the user sees as the completion option instead of the actual text.

public int getPosition ()

Added in API level 3

Return the original position of this completion, typically corresponding to its position in the original adapter.

public CharSequence getText ()

Added in API level 3

Return the actual text associated with this completion. This is the real text that will be inserted into the editor if the user selects it.

public String toString ()

Added in API level 3

Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:

          getClass().getName() + '@' + Integer.toHexString(hashCode())
         

See Writing a useful toString method if you intend implementing your own toString method.

Returns
  • a printable representation of this object.

public void writeToParcel ( Parcel dest, int flags)

Added in API level 3

Used to package this object into a Parcel .

Parameters
dest The Parcel to be written.
flags The flags used for parceling.