public final class Autocomplete<T>
extends java.lang.Object
implements android.text.TextWatcher, android.text.SpanWatcher
EditText.
You can construct a Autocomplete using the builder provided by on(EditText).
Building is enough, but you can hold a reference to this class to call its public methods.
Requires:
- EditText: this is both the anchor for the popup, and the source of text events that we listen to
- AutocompletePresenter: this presents items in the popup window. See class for more info.
- AutocompleteCallback: if specified, this listens to click events and visibility changes
- AutocompletePolicy: if specified, this controls how and when to show the popup based on text events
If not, this defaults to Autocomplete.SimplePolicy: shows the popup when text.length() bigger than 0.| Modifier and Type | Class and Description |
|---|---|
static class |
Autocomplete.Builder<T>
Builder for building
Autocomplete. |
static class |
Autocomplete.SimplePolicy
A very simple
AutocompletePolicy implementation. |
| Modifier and Type | Method and Description |
|---|---|
void |
afterTextChanged(android.text.Editable s) |
void |
beforeTextChanged(java.lang.CharSequence s,
int start,
int count,
int after) |
void |
dismissPopup()
Dismisses the popup, if showing.
|
boolean |
isPopupShowing()
Returns true if the popup is showing.
|
static <T> Autocomplete.Builder<T> |
on(android.widget.EditText anchor)
Entry point for building autocomplete on a certain
EditText. |
void |
onSpanAdded(android.text.Spannable text,
java.lang.Object what,
int start,
int end) |
void |
onSpanChanged(android.text.Spannable text,
java.lang.Object what,
int ostart,
int oend,
int nstart,
int nend) |
void |
onSpanRemoved(android.text.Spannable text,
java.lang.Object what,
int start,
int end) |
void |
onTextChanged(java.lang.CharSequence s,
int start,
int before,
int count) |
void |
setEnabled(boolean enabled)
Switch to control the autocomplete behavior.
|
void |
setGravity(int gravity)
Sets the gravity for the popup.
|
void |
setOffsetFromAnchor(int offset)
Controls the vertical offset of the popup from the EditText anchor.
|
void |
setOutsideTouchable(boolean outsideTouchable)
Controls whether the popup should listen to clicks outside its boundaries.
|
void |
showPopup(java.lang.CharSequence query)
Shows the popup with the given query.
|
public static <T> Autocomplete.Builder<T> on(android.widget.EditText anchor)
EditText.T - your data modelanchor - the anchor for the popup, and the source of text eventspublic void showPopup(java.lang.CharSequence query)
AutocompletePolicy.query - query text.public void dismissPopup()
AutocompletePolicy.public boolean isPopupShowing()
public void setEnabled(boolean enabled)
enabled - whether to enable autocompletionpublic void setGravity(int gravity)
Gravity.START and Gravity.END
do work.gravity - gravity for the popuppublic void setOffsetFromAnchor(int offset)
offset - offset in pixels.public void setOutsideTouchable(boolean outsideTouchable)
outsideTouchable - true to listen to outside clickspublic void beforeTextChanged(java.lang.CharSequence s,
int start,
int count,
int after)
beforeTextChanged in interface android.text.TextWatcherpublic void onTextChanged(java.lang.CharSequence s,
int start,
int before,
int count)
onTextChanged in interface android.text.TextWatcherpublic void afterTextChanged(android.text.Editable s)
afterTextChanged in interface android.text.TextWatcherpublic void onSpanAdded(android.text.Spannable text,
java.lang.Object what,
int start,
int end)
onSpanAdded in interface android.text.SpanWatcherpublic void onSpanRemoved(android.text.Spannable text,
java.lang.Object what,
int start,
int end)
onSpanRemoved in interface android.text.SpanWatcherpublic void onSpanChanged(android.text.Spannable text,
java.lang.Object what,
int ostart,
int oend,
int nstart,
int nend)
onSpanChanged in interface android.text.SpanWatcher