public final class CompletionInfo extends Object implements Parcelable
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
AutoCompleteTextView
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
InputMethodManager.displayCompletions(View, CompletionInfo[])
.
The IME would present the completions however they see fit, and
call back to the editor through
InputConnection.commitCompletion(CompletionInfo)
.
The application can then pick up the commit event by overriding
TextView.onCommitCompletion(CompletionInfo)
.
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Modifier and Type | Field and Description |
---|---|
static Parcelable.Creator<CompletionInfo> |
CREATOR
Used to make this class parcelable.
|
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_ELIDE_DUPLICATES, PARCELABLE_WRITE_RETURN_VALUE
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
int |
describeContents()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled 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 representation of the object.
|
void |
writeToParcel(Parcel dest,
int flags)
Used to package this object into a
Parcel . |
public static final Parcelable.Creator<CompletionInfo> CREATOR
public CompletionInfo(long id, int index, CharSequence text)
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)
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 long getId()
public int getPosition()
public CharSequence getText()
public CharSequence getLabel()
public String toString()
Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
public void writeToParcel(Parcel dest, int flags)
Parcel
.writeToParcel
in interface Parcelable
dest
- The Parcel
to be written.flags
- The flags used for parceling.public int describeContents()
Parcelable
Parcelable.writeToParcel(Parcel, int)
,
the return value of this method must include the
Parcelable.CONTENTS_FILE_DESCRIPTOR
bit.describeContents
in interface Parcelable
Parcelable.CONTENTS_FILE_DESCRIPTOR