switch (mAutoCompleteMode){ case AUTOCOMPLETE_MODE_SINGLE: mInputView = new InternalAutoCompleteTextView(context, attrs, defStyleAttr); break; case AUTOCOMPLETE_MODE_MULTI:
/** * Called when an attached input method calls * {@link InputConnection#performEditorAction(int) * InputConnection.performEditorAction()} * for this text view. The default implementation will call your action * listener supplied to {@link #setOnEditorActionListener}, or perform * a standard operation for {@link EditorInfo#IME_ACTION_NEXT * EditorInfo.IME_ACTION_NEXT}, {@link EditorInfo#IME_ACTION_PREVIOUS * EditorInfo.IME_ACTION_PREVIOUS}, or {@link EditorInfo#IME_ACTION_DONE * EditorInfo.IME_ACTION_DONE}. * * <p>For backwards compatibility, if no IME options have been set and the * text view would not normally advance focus on enter, then * the NEXT and DONE actions received here will be turned into an enter * key down/up pair to go through the normal key handling. * * @param actionCode The code of the action being performed. * * @see #setOnEditorActionListener */ public void onEditorAction (int actionCode){ if(mAutoCompleteMode == AUTOCOMPLETE_MODE_NONE) ((InternalEditText)mInputView).superOnEditorAction(actionCode); else if(mAutoCompleteMode == AUTOCOMPLETE_MODE_SINGLE) ((InternalAutoCompleteTextView)mInputView).superOnEditorAction(actionCode); else ((InternalMultiAutoCompleteTextView)mInputView).superOnEditorAction(actionCode); }
/** * <p>Converts the selected item from the drop down list into a sequence * of character that can be used in the edit box.</p> * * @param selectedItem the item selected by the user for completion * * @return a sequence of characters representing the selected suggestion */ protected CharSequence convertSelectionToString(Object selectedItem) { switch (mAutoCompleteMode){ case AUTOCOMPLETE_MODE_SINGLE: return ((InternalAutoCompleteTextView)mInputView).superConvertSelectionToString(selectedItem); case AUTOCOMPLETE_MODE_MULTI: return ((InternalMultiAutoCompleteTextView)mInputView).superConvertSelectionToString(selectedItem); default: return null; } }
/** * Called by the framework in response to a text auto-correction (such as fixing a typo using a * a dictionnary) from the current input method, provided by it calling * {@link InputConnection#commitCorrection} InputConnection.commitCorrection()}. The default * implementation flashes the background of the corrected word to provide feedback to the user. * * @param info The auto correct info about the text that was corrected. */ public void onCommitCorrection (CorrectionInfo info){ if(mAutoCompleteMode == AUTOCOMPLETE_MODE_NONE) ((InternalEditText)mInputView).superOnCommitCorrection(info); else if(mAutoCompleteMode == AUTOCOMPLETE_MODE_SINGLE) ((InternalAutoCompleteTextView)mInputView).superOnCommitCorrection(info); else ((InternalMultiAutoCompleteTextView)mInputView).superOnCommitCorrection(info); }
/** * Called by the framework in response to a text completion from * the current input method, provided by it calling * {@link InputConnection#commitCompletion * InputConnection.commitCompletion()}. The default implementation does * nothing; text views that are supporting auto-completion should override * this to do their desired behavior. * * @param text The auto complete text the user has selected. */ public void onCommitCompletion (CompletionInfo text){ if(mAutoCompleteMode == AUTOCOMPLETE_MODE_NONE) ((InternalEditText)mInputView).superOnCommitCompletion(text); else if(mAutoCompleteMode == AUTOCOMPLETE_MODE_SINGLE) ((InternalAutoCompleteTextView)mInputView).superOnCommitCompletion(text); else ((InternalMultiAutoCompleteTextView)mInputView).superOnCommitCompletion(text); }
/** * Returns the Filter obtained from {@link Filterable#getFilter}, * or <code>null</code> if {@link #setAdapter} was not called with * a Filterable. */ protected Filter getFilter() { switch (mAutoCompleteMode){ case AUTOCOMPLETE_MODE_SINGLE: return ((InternalAutoCompleteTextView)mInputView).superGetFilter(); case AUTOCOMPLETE_MODE_MULTI: return ((InternalMultiAutoCompleteTextView)mInputView).superGetFilter(); default: return null; } }
@Override public boolean onKeyDown (int keyCode, KeyEvent event){ if(mAutoCompleteMode == AUTOCOMPLETE_MODE_NONE) return ((InternalEditText)mInputView).superOnKeyDown(keyCode, event); else if(mAutoCompleteMode == AUTOCOMPLETE_MODE_SINGLE) return ((InternalAutoCompleteTextView)mInputView).superOnKeyDown(keyCode, event); else return ((InternalMultiAutoCompleteTextView)mInputView).superOnKeyDown(keyCode, event); }
/** <p>Only work when autoComplete mode is {@link #AUTOCOMPLETE_MODE_SINGLE} or {@link #AUTOCOMPLETE_MODE_MULTI}</p> */ public void onFilterComplete(int count) { if(mAutoCompleteMode == AUTOCOMPLETE_MODE_SINGLE) ((InternalAutoCompleteTextView)mInputView).superOnFilterComplete(count); else if(mAutoCompleteMode == AUTOCOMPLETE_MODE_MULTI) ((InternalMultiAutoCompleteTextView)mInputView).superOnFilterComplete(count); }
@Override public boolean onKeyMultiple (int keyCode, int repeatCount, KeyEvent event){ if(mAutoCompleteMode == AUTOCOMPLETE_MODE_NONE) return ((InternalEditText)mInputView).superOnKeyMultiple(keyCode, repeatCount, event); else if(mAutoCompleteMode == AUTOCOMPLETE_MODE_SINGLE) return ((InternalAutoCompleteTextView)mInputView).superOnKeyMultiple(keyCode, repeatCount, event); else return ((InternalMultiAutoCompleteTextView)mInputView).superOnKeyMultiple(keyCode, repeatCount, event); }
@Override public InputConnection onCreateInputConnection (EditorInfo outAttrs){ if(mAutoCompleteMode == AUTOCOMPLETE_MODE_NONE) return ((InternalEditText)mInputView).superOnCreateInputConnection(outAttrs); else if(mAutoCompleteMode == AUTOCOMPLETE_MODE_SINGLE) return ((InternalAutoCompleteTextView)mInputView).superOnCreateInputConnection(outAttrs); else return ((InternalMultiAutoCompleteTextView)mInputView).superOnCreateInputConnection(outAttrs); }