Build 1.0_r1(from source)

android.widget
Class MultiAutoCompleteTextView

java.lang.Object
  extended by android.view.View
      extended by android.widget.TextView
          extended by android.widget.EditText
              extended by android.widget.AutoCompleteTextView
                  extended by android.widget.MultiAutoCompleteTextView
All Implemented Interfaces:
Drawable.Callback, KeyEvent.Callback, ViewTreeObserver.OnPreDrawListener, Filter.FilterListener

public class MultiAutoCompleteTextView
extends AutoCompleteTextView

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
 
Fields inherited from class android.view.View
DRAWING_CACHE_QUALITY_AUTO, DRAWING_CACHE_QUALITY_HIGH, DRAWING_CACHE_QUALITY_LOW, EMPTY_STATE_SET, ENABLED_FOCUSED_SELECTED_STATE_SET, ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_FOCUSED_STATE_SET, ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, ENABLED_SELECTED_STATE_SET, ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_STATE_SET, ENABLED_WINDOW_FOCUSED_STATE_SET, FIRST_STATE_SET, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSED_SELECTED_STATE_SET, FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, FOCUSED_STATE_SET, FOCUSED_WINDOW_FOCUSED_STATE_SET, GONE, INVISIBLE, KEEP_SCREEN_ON, LAST_STATE_SET, mBottom, mContext, mCurrentAnimation, MIDDLE_STATE_SET, mLayoutParams, mLeft, mLocation, mMeasuredHeight, mMeasuredWidth, mOnClickListener, mOnCreateContextMenuListener, mOnFocusChangeListener, mOnLongClickListener, mPaddingBottom, mPaddingLeft, mPaddingRight, mPaddingTop, mParent, mRight, mScrollX, mScrollY, mTag, mTop, NO_ID, PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET, PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_SELECTED_STATE_SET, PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_STATE_SET, PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET, PRESSED_FIRST_STATE_SET, PRESSED_FOCUSED_SELECTED_STATE_SET, PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_STATE_SET, PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_LAST_STATE_SET, PRESSED_MIDDLE_STATE_SET, PRESSED_SELECTED_STATE_SET, PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_SINGLE_STATE_SET, PRESSED_STATE_SET, PRESSED_WINDOW_FOCUSED_STATE_SET, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SINGLE_STATE_SET, SOUND_EFFECTS_ENABLED, VIEW_LOG_TAG, VISIBLE, WINDOW_FOCUSED_STATE_SET
 
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.AutoCompleteTextView
convertSelectionToString, dismissDropDown, getAdapter, getFilter, getItemClickListener, getItemSelectedListener, getThreshold, getValidator, isPopupShowing, onFilterComplete, onFocusChanged, onKeyDown, onKeyUp, onTextChanged, onWindowFocusChanged, performCompletion, setAdapter, setCompletionHint, setFrame, setOnItemClickListener, setOnItemSelectedListener, setThreshold, setValidator, showDropDown
 
Methods inherited from class android.widget.EditText
extendSelection, getDefaultEditable, getDefaultMovementMethod, getText, selectAll, setSelection, setSelection, setText
 
Methods inherited from class android.widget.TextView
addTextChangedListener, append, append, computeHorizontalScrollRange, computeScroll, computeVerticalScrollRange, debug, drawableStateChanged, getAutoLinkMask, getBaseline, getCompoundDrawablePadding, getCompoundDrawables, getCompoundPaddingBottom, getCompoundPaddingLeft, getCompoundPaddingRight, getCompoundPaddingTop, getCurrentHintTextColor, getCurrentTextColor, getEllipsize, getError, getExtendedPaddingBottom, getExtendedPaddingTop, getFilters, getFocusedRect, getFreezesText, getGravity, getHint, getHintTextColors, getKeyListener, getLayout, getLineBounds, getLineCount, getLineHeight, getLinksClickable, getLinkTextColors, getMovementMethod, getPaint, getPaintFlags, getSelectionEnd, getSelectionStart, getTextColor, getTextColors, getTextColors, getTextScaleX, getTextSize, getTotalPaddingBottom, getTotalPaddingLeft, getTotalPaddingRight, getTotalPaddingTop, getTransformationMethod, getTypeface, getUrls, hasSelection, length, makeNewLayout, onCreateContextMenu, onDetachedFromWindow, onDraw, onKeyShortcut, onMeasure, onPreDraw, onRestoreInstanceState, onSaveInstanceState, onTouchEvent, onTrackballEvent, performLongClick, removeTextChangedListener, setAutoLinkMask, setCompoundDrawablePadding, setCompoundDrawables, setCompoundDrawablesWithIntrinsicBounds, setCursorVisible, setEditableFactory, setEllipsize, setEms, setError, setError, setFilters, setFreezesText, setGravity, setHeight, setHighlightColor, setHint, setHint, setHintTextColor, setHintTextColor, setHorizontallyScrolling, setIncludeFontPadding, setKeyListener, setLines, setLineSpacing, setLinksClickable, setLinkTextColor, setLinkTextColor, setMaxEms, setMaxHeight, setMaxLines, setMaxWidth, setMinEms, setMinHeight, setMinLines, setMinWidth, setMovementMethod, setPadding, setPaintFlags, setScroller, setSelectAllOnFocus, setShadowLayer, setSingleLine, setSingleLine, setSpannableFactory, setText, setText, setText, setText, setTextAppearance, setTextColor, setTextColor, setTextKeepState, setTextKeepState, setTextScaleX, setTextSize, setTextSize, setTransformationMethod, setTypeface, setTypeface, setWidth
 
Methods inherited from class android.view.View
addFocusables, addTouchables, applyDrawableToTransparentRegion, bringToFront, buildDrawingCache, cancelLongPress, clearAnimation, clearFocus, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeVerticalScrollExtent, computeVerticalScrollOffset, createContextMenu, debug, debugIndent, destroyDrawingCache, dispatchDraw, dispatchKeyEvent, dispatchKeyShortcutEvent, dispatchRestoreInstanceState, dispatchSaveInstanceState, dispatchSetPressed, dispatchSetSelected, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchWindowFocusChanged, dispatchWindowVisibilityChanged, draw, finalize, findFocus, findViewById, findViewTraversal, findViewWithTag, findViewWithTagTraversal, fitSystemWindows, focusSearch, forceLayout, gatherTransparentRegion, getAnimation, getApplicationWindowToken, getBackground, getBottom, getBottomFadingEdgeStrength, getContext, getContextMenuInfo, getDefaultSize, getDrawableState, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getFocusables, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getId, getKeepScreenOn, getLayoutParams, getLeft, getLeftFadingEdgeStrength, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMeasuredHeight, getMeasuredWidth, getNextFocusDownId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, getParent, getResources, getRight, getRightFadingEdgeStrength, getRootView, getScrollBarStyle, getScrollX, getScrollY, getSolidColor, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getTag, getTop, getTopFadingEdgeStrength, getTouchables, getTouchDelegate, getVerticalFadingEdgeLength, getVerticalScrollbarWidth, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowToken, getWindowVisibility, hasFocus, hasFocusable, hasWindowFocus, inflate, initializeFadingEdge, initializeScrollbars, invalidate, invalidate, invalidate, invalidateDrawable, isClickable, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isInTouchMode, isLayoutRequested, isLongClickable, isPressed, isRootNamespace, isSaveEnabled, isSelected, isShown, isSoundEffectsEnabled, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, layout, measure, mergeDrawableStates, offsetLeftAndRight, offsetTopAndBottom, onAnimationEnd, onAnimationStart, onAttachedToWindow, onCreateDrawableState, onFinishInflate, onKeyMultiple, onLayout, onScrollChanged, onSetAlpha, onSizeChanged, onWindowVisibilityChanged, performClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, refreshDrawableState, removeCallbacks, requestFocus, requestFocus, requestFocus, requestFocusFromTouch, requestLayout, requestRectangleOnScreen, requestRectangleOnScreen, resolveSize, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, setAnimation, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setClickable, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setEnabled, setFadingEdgeLength, setFocusable, setFocusableInTouchMode, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setId, setIsRootNamespace, setKeepScreenOn, setLayoutParams, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNextFocusDownId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnClickListener, setOnCreateContextMenuListener, setOnFocusChangeListener, setOnKeyListener, setOnLongClickListener, setOnTouchListener, setPressed, setSaveEnabled, setScrollBarStyle, setSelected, setSoundEffectsEnabled, setTag, setTouchDelegate, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVisibility, setWillNotCacheDrawing, setWillNotDraw, showContextMenu, startAnimation, unscheduleDrawable, unscheduleDrawable, verifyDrawable, willNotCacheDrawing, willNotDraw
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiAutoCompleteTextView

public MultiAutoCompleteTextView(Context context)

MultiAutoCompleteTextView

public MultiAutoCompleteTextView(Context context,
                                 AttributeSet attrs)

MultiAutoCompleteTextView

public MultiAutoCompleteTextView(Context context,
                                 AttributeSet attrs,
                                 int defStyle)
Method Detail

finishInit

void finishInit()
Description copied from class: AutoCompleteTextView
Sets this to be single line; a separate method so MultiAutoCompleteTextView can skip this.

Overrides:
finishInit in class AutoCompleteTextView

setTokenizer

public 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.


performFiltering

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().

Overrides:
performFiltering in class AutoCompleteTextView
Parameters:
text - the filtering pattern
keyCode - the last character inserted in the edit box

enoughToFilter

public 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().

Overrides:
enoughToFilter in class AutoCompleteTextView

performValidation

public void performValidation()
Instead of validating the entire text, this subclass method validates each token of the text individually. Empty tokens are removed.

Overrides:
performValidation in class AutoCompleteTextView

performFiltering

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.


replaceText

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.

Overrides:
replaceText in class AutoCompleteTextView
Parameters:
text - the selected suggestion in the drop down list

Build 1.0_r1(from source)

Please submit a feedback, bug or feature