From 076357b8567458d4b6dfdcf839ef751634cd2bfb Mon Sep 17 00:00:00 2001 From: The Android Open Source Project Date: Tue, 3 Mar 2009 14:04:24 -0800 Subject: auto import from //depot/cupcake/@132589 --- core/java/android/widget/AutoCompleteTextView.java | 103 +-------------------- 1 file changed, 5 insertions(+), 98 deletions(-) (limited to 'core/java/android/widget/AutoCompleteTextView.java') diff --git a/core/java/android/widget/AutoCompleteTextView.java b/core/java/android/widget/AutoCompleteTextView.java index 0c1c72ab170c..7a51676bf768 100644 --- a/core/java/android/widget/AutoCompleteTextView.java +++ b/core/java/android/widget/AutoCompleteTextView.java @@ -78,8 +78,6 @@ import com.android.internal.R; * @attr ref android.R.styleable#AutoCompleteTextView_completionThreshold * @attr ref android.R.styleable#AutoCompleteTextView_completionHintView * @attr ref android.R.styleable#AutoCompleteTextView_dropDownSelector - * @attr ref android.R.styleable#AutoCompleteTextView_dropDownAnchor - * @attr ref android.R.styleable#AutoCompleteTextView_dropDownWidth */ public class AutoCompleteTextView extends EditText implements Filter.FilterListener { static final boolean DEBUG = false; @@ -98,9 +96,6 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe private DropDownListView mDropDownList; private int mDropDownVerticalOffset; private int mDropDownHorizontalOffset; - private int mDropDownAnchorId; - private View mDropDownAnchorView; // view is retrieved lazily from id once needed - private int mDropDownWidth; private Drawable mDropDownListHighlight; @@ -152,18 +147,6 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe a.getDimension(R.styleable.AutoCompleteTextView_dropDownVerticalOffset, 0.0f); mDropDownHorizontalOffset = (int) a.getDimension(R.styleable.AutoCompleteTextView_dropDownHorizontalOffset, 0.0f); - - // Get the anchor's id now, but the view won't be ready, so wait to actually get the - // view and store it in mDropDownAnchorView lazily in getDropDownAnchorView later. - // Defaults to NO_ID, in which case the getDropDownAnchorView method will simply return - // this TextView, as a default anchoring point. - mDropDownAnchorId = a.getResourceId(R.styleable.AutoCompleteTextView_dropDownAnchor, - View.NO_ID); - - // For dropdown width, the developer can specify a specific width, or FILL_PARENT - // (for full screen width) or WRAP_CONTENT (to match the width of the anchored view). - mDropDownWidth = a.getLayoutDimension(R.styleable.AutoCompleteTextView_dropDownWidth, - ViewGroup.LayoutParams.WRAP_CONTENT); mHintResource = a.getResourceId(R.styleable.AutoCompleteTextView_completionHintView, R.layout.simple_dropdown_hint); @@ -204,49 +187,6 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe public void setCompletionHint(CharSequence hint) { mHintText = hint; } - - /** - *

Returns the current width for the auto-complete drop down list. This can - * be a fixed width, or {@link ViewGroup.LayoutParams#FILL_PARENT} to fill the screen, or - * {@link ViewGroup.LayoutParams#WRAP_CONTENT} to fit the width of its anchor view.

- * - * @return the width for the drop down list - */ - public int getDropDownWidth() { - return mDropDownWidth; - } - - /** - *

Sets the current width for the auto-complete drop down list. This can - * be a fixed width, or {@link ViewGroup.LayoutParams#FILL_PARENT} to fill the screen, or - * {@link ViewGroup.LayoutParams#WRAP_CONTENT} to fit the width of its anchor view.

- * - * @param width the width to use - */ - public void setDropDownWidth(int width) { - mDropDownWidth = width; - } - - /** - *

Returns the id for the view that the auto-complete drop down list is anchored to.

- * - * @return the view's id, or {@link View#NO_ID} if none specified - */ - public int getDropDownAnchor() { - return mDropDownAnchorId; - } - - /** - *

Sets the view to which the auto-complete drop down list should anchor. The view - * corresponding to this id will not be loaded until the next time it is needed to avoid - * loading a view which is not yet instantiated.

- * - * @param id the id to anchor the drop down list view to - */ - public void setDropDownAnchor(int id) { - mDropDownAnchorId = id; - mDropDownAnchorView = null; - } /** *

Returns the number of characters the user must type before the drop @@ -801,18 +741,6 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe return result; } - - /** - *

Used for lazy instantiation of the anchor view from the id we have. If the value of - * the id is NO_ID or we can't find a view for the given id, we return this TextView as - * the default anchoring point.

- */ - private View getDropDownAnchorView() { - if (mDropDownAnchorView == null && mDropDownAnchorId != View.NO_ID) { - mDropDownAnchorView = getRootView().findViewById(mDropDownAnchorId); - } - return mDropDownAnchorView == null ? this : mDropDownAnchorView; - } /** *

Displays the drop down on screen.

@@ -820,37 +748,16 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe public void showDropDown() { int height = buildDropDown(); if (mPopup.isShowing()) { - int widthSpec; - if (mDropDownWidth == ViewGroup.LayoutParams.FILL_PARENT) { - // The call to PopupWindow's update method below can accept -1 for any - // value you do not want to update. - widthSpec = -1; - } else if (mDropDownWidth == ViewGroup.LayoutParams.WRAP_CONTENT) { - widthSpec = getDropDownAnchorView().getWidth(); - } else { - widthSpec = mDropDownWidth; - } - mPopup.update(getDropDownAnchorView(), mDropDownHorizontalOffset, - mDropDownVerticalOffset, widthSpec, height); + mPopup.update(this, mDropDownHorizontalOffset, mDropDownVerticalOffset, + getWidth(), height); } else { - int widthSpec; - if (mDropDownWidth == ViewGroup.LayoutParams.FILL_PARENT) { - mPopup.setWindowLayoutMode(ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT); - } else { - mPopup.setWindowLayoutMode(0, ViewGroup.LayoutParams.WRAP_CONTENT); - if (mDropDownWidth == ViewGroup.LayoutParams.WRAP_CONTENT) { - mPopup.setWidth(getDropDownAnchorView().getWidth()); - } else { - mPopup.setWidth(mDropDownWidth); - } - } + mPopup.setWindowLayoutMode(0, ViewGroup.LayoutParams.WRAP_CONTENT); + mPopup.setWidth(getWidth()); mPopup.setHeight(height); mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED); mPopup.setOutsideTouchable(true); mPopup.setTouchInterceptor(new PopupTouchIntercepter()); - mPopup.showAsDropDown(getDropDownAnchorView(), - mDropDownHorizontalOffset, mDropDownVerticalOffset); + mPopup.showAsDropDown(this, mDropDownHorizontalOffset, mDropDownVerticalOffset); mDropDownList.setSelection(ListView.INVALID_POSITION); mDropDownList.hideSelector(); mDropDownList.requestFocus(); -- cgit v1.2.3