|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectandroid.view.View
android.widget.TextView
android.widget.EditText
android.widget.AutoCompleteTextView
android.widget.MultiAutoCompleteTextView
public class MultiAutoCompleteTextView
An editable text view, extending AutoCompleteTextView, that
can show completion suggestions for the substring of the text where
the user is typing instead of necessarily for the entire thing.
You must must provide a MultiAutoCompleteTextView.Tokenizer to distinguish the
various substrings.
The following code snippet shows how to create a text view which suggests various countries names while the user is typing:
public class CountriesActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.autocomplete_7);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line, COUNTRIES);
MultiAutoCompleteTextView textView = (MultiAutoCompleteTextView) findViewById(R.id.edit);
textView.setAdapter(adapter);
textView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
}
private static final String[] COUNTRIES = new String[] {
"Belgium", "France", "Italy", "Germany", "Spain"
};
}
| Nested Class Summary | |
|---|---|
static class |
MultiAutoCompleteTextView.CommaTokenizer
This simple Tokenizer can be used for lists where the items are separated by a comma and one or more spaces. |
static interface |
MultiAutoCompleteTextView.Tokenizer
|
| Nested classes/interfaces inherited from class android.widget.AutoCompleteTextView |
|---|
AutoCompleteTextView.Validator |
| Nested classes/interfaces inherited from class android.widget.TextView |
|---|
TextView.BufferType, TextView.SavedState |
| Nested classes/interfaces inherited from class android.view.View |
|---|
View.BaseSavedState, View.MeasureSpec, View.OnClickListener, View.OnCreateContextMenuListener, View.OnFocusChangeListener, View.OnKeyListener, View.OnLongClickListener, View.OnTouchListener |
| Field Summary |
|---|
| Constructor Summary | |
|---|---|
MultiAutoCompleteTextView(Context context)
|
|
MultiAutoCompleteTextView(Context context,
AttributeSet attrs)
|
|
MultiAutoCompleteTextView(Context context,
AttributeSet attrs,
int defStyle)
|
|
| Method Summary | |
|---|---|
boolean |
enoughToFilter()
Instead of filtering whenever the total length of the text exceeds the threshhold, this subclass filters only when the length of the range from MultiAutoCompleteTextView.Tokenizer.findTokenStart(java.lang.CharSequence, int) to TextView.getSelectionEnd()
meets or exceeds AutoCompleteTextView.getThreshold(). |
(package private) void |
finishInit()
Sets this to be single line; a separate method so MultiAutoCompleteTextView can skip this. |
protected void |
performFiltering(CharSequence text,
int keyCode)
Instead of filtering on the entire contents of the edit box, this subclass method filters on the range from MultiAutoCompleteTextView.Tokenizer.findTokenStart(java.lang.CharSequence, int) to TextView.getSelectionEnd()
if the length of that range meets or exceeds AutoCompleteTextView.getThreshold(). |
protected void |
performFiltering(CharSequence text,
int start,
int end,
int keyCode)
Starts filtering the content of the drop down list. |
void |
performValidation()
Instead of validating the entire text, this subclass method validates each token of the text individually. |
protected void |
replaceText(CharSequence text)
Performs the text completion by replacing the range from MultiAutoCompleteTextView.Tokenizer.findTokenStart(java.lang.CharSequence, int) to TextView.getSelectionEnd() by the
the result of passing text through
MultiAutoCompleteTextView.Tokenizer.terminateToken(java.lang.CharSequence). |
void |
setTokenizer(MultiAutoCompleteTextView.Tokenizer t)
Sets the Tokenizer that will be used to determine the relevant range of the text where the user is typing. |
| Methods inherited from class android.widget.EditText |
|---|
extendSelection, getDefaultEditable, getDefaultMovementMethod, getText, selectAll, setSelection, setSelection, setText |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MultiAutoCompleteTextView(Context context)
public MultiAutoCompleteTextView(Context context,
AttributeSet attrs)
public MultiAutoCompleteTextView(Context context,
AttributeSet attrs,
int defStyle)
| Method Detail |
|---|
void finishInit()
AutoCompleteTextView
finishInit in class AutoCompleteTextViewpublic void setTokenizer(MultiAutoCompleteTextView.Tokenizer t)
protected void performFiltering(CharSequence text,
int keyCode)
MultiAutoCompleteTextView.Tokenizer.findTokenStart(java.lang.CharSequence, int) to TextView.getSelectionEnd()
if the length of that range meets or exceeds AutoCompleteTextView.getThreshold().
performFiltering in class AutoCompleteTextViewtext - the filtering patternkeyCode - the last character inserted in the edit boxpublic boolean enoughToFilter()
MultiAutoCompleteTextView.Tokenizer.findTokenStart(java.lang.CharSequence, int) to TextView.getSelectionEnd()
meets or exceeds AutoCompleteTextView.getThreshold().
enoughToFilter in class AutoCompleteTextViewpublic void performValidation()
performValidation in class AutoCompleteTextView
protected void performFiltering(CharSequence text,
int start,
int end,
int keyCode)
Starts filtering the content of the drop down list. The filtering
pattern is the specified range of text from the edit box. Subclasses may
override this method to filter with a different pattern, for
instance a smaller substring of text.
protected void replaceText(CharSequence text)
Performs the text completion by replacing the range from
MultiAutoCompleteTextView.Tokenizer.findTokenStart(java.lang.CharSequence, int) to TextView.getSelectionEnd() by the
the result of passing text through
MultiAutoCompleteTextView.Tokenizer.terminateToken(java.lang.CharSequence).
In addition, the replaced region will be marked as an AutoText
substition so that if the user immediately presses DEL, the
completion will be undone.
Subclasses may override this method to do some different
insertion of the content into the edit box.
replaceText in class AutoCompleteTextViewtext - the selected suggestion in the drop down list
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||