public
final
class
CompletionInfo
extends Object
implements
Parcelable
java.lang.Object | |
↳ | android.view.inputmethod.CompletionInfo |
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)
.
See also:
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 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 |
Inherited methods | |
---|---|
From
class
java.lang.Object
| |
From
interface
android.os.Parcelable
|
CompletionInfo (long id, int index, CharSequence text)
Create a simple completion with just text, no label.
Parameters | |
---|---|
id |
long :
An id that get passed as is (to the editor's discretion) |
index |
int :
An index that get passed as is. Typically this is the
index in the list of completions inside the editor. |
text |
CharSequence :
The text that should be inserted into the editor when
this completion is chosen.
|
CompletionInfo (long id, int index, CharSequence text, CharSequence label)
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 |
long :
An id that get passed as is (to the editor's discretion) |
index |
int :
An index that get passed as is. Typically this is the
index in the list of completions inside the editor. |
text |
CharSequence :
The text that should be inserted into the editor when
this completion is chosen. |
label |
CharSequence :
The text that the IME should be showing among the
completions list.
|
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(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. |
long getId ()
Return the abstract identifier for this completion, typically corresponding to the id associated with it in the original adapter.
Returns | |
---|---|
long |
CharSequence getLabel ()
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.
Returns | |
---|---|
CharSequence |
int getPosition ()
Return the original position of this completion, typically corresponding to its position in the original adapter.
Returns | |
---|---|
int |
CharSequence getText ()
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.
Returns | |
---|---|
CharSequence |
String toString ()
Returns a string representation of the object. In general, the
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())
Returns | |
---|---|
String |
a string representation of the object. |
void writeToParcel (Parcel dest, int flags)
Used to package this object into a Parcel
.
Parameters | |
---|---|
dest |
Parcel :
The Parcel to be written. |
flags |
int :
The flags used for parceling.
|