summaryrefslogtreecommitdiff
path: root/core/java/android/widget/AutoCompleteTextView.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/widget/AutoCompleteTextView.java')
-rw-r--r--core/java/android/widget/AutoCompleteTextView.java106
1 files changed, 54 insertions, 52 deletions
diff --git a/core/java/android/widget/AutoCompleteTextView.java b/core/java/android/widget/AutoCompleteTextView.java
index 6a4e36a9a578..49741d4d111e 100644
--- a/core/java/android/widget/AutoCompleteTextView.java
+++ b/core/java/android/widget/AutoCompleteTextView.java
@@ -39,7 +39,9 @@ import android.view.WindowManager;
import android.view.inputmethod.CompletionInfo;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
+
import com.android.internal.R;
+
import java.lang.ref.WeakReference;
/**
@@ -362,22 +364,22 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
* <p>Returns the current width for the auto-complete drop down list. This can
* be a fixed width, or {@link ViewGroup.LayoutParams#MATCH_PARENT} to fill the screen, or
* {@link ViewGroup.LayoutParams#WRAP_CONTENT} to fit the width of its anchor view.</p>
- *
+ *
* @return the width for the drop down list
- *
+ *
* @attr ref android.R.styleable#AutoCompleteTextView_dropDownWidth
*/
public int getDropDownWidth() {
return mPopup.getWidth();
}
-
+
/**
* <p>Sets the current width for the auto-complete drop down list. This can
* be a fixed width, or {@link ViewGroup.LayoutParams#MATCH_PARENT} to fill the screen, or
* {@link ViewGroup.LayoutParams#WRAP_CONTENT} to fit the width of its anchor view.</p>
- *
+ *
* @param width the width to use
- *
+ *
* @attr ref android.R.styleable#AutoCompleteTextView_dropDownWidth
*/
public void setDropDownWidth(int width) {
@@ -411,68 +413,68 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
public void setDropDownHeight(int height) {
mPopup.setHeight(height);
}
-
+
/**
* <p>Returns the id for the view that the auto-complete drop down list is anchored to.</p>
- *
+ *
* @return the view's id, or {@link View#NO_ID} if none specified
- *
+ *
* @attr ref android.R.styleable#AutoCompleteTextView_dropDownAnchor
*/
public int getDropDownAnchor() {
return mDropDownAnchorId;
}
-
+
/**
* <p>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.</p>
- *
+ *
* @param id the id to anchor the drop down list view to
- *
- * @attr ref android.R.styleable#AutoCompleteTextView_dropDownAnchor
+ *
+ * @attr ref android.R.styleable#AutoCompleteTextView_dropDownAnchor
*/
public void setDropDownAnchor(int id) {
mDropDownAnchorId = id;
mPopup.setAnchorView(null);
}
-
+
/**
* <p>Gets the background of the auto-complete drop-down list.</p>
- *
+ *
* @return the background drawable
- *
+ *
* @attr ref android.R.styleable#PopupWindow_popupBackground
*/
public Drawable getDropDownBackground() {
return mPopup.getBackground();
}
-
+
/**
* <p>Sets the background of the auto-complete drop-down list.</p>
- *
+ *
* @param d the drawable to set as the background
- *
+ *
* @attr ref android.R.styleable#PopupWindow_popupBackground
*/
public void setDropDownBackgroundDrawable(Drawable d) {
mPopup.setBackgroundDrawable(d);
}
-
+
/**
* <p>Sets the background of the auto-complete drop-down list.</p>
- *
+ *
* @param id the id of the drawable to set as the background
- *
+ *
* @attr ref android.R.styleable#PopupWindow_popupBackground
*/
public void setDropDownBackgroundResource(@DrawableRes int id) {
mPopup.setBackgroundDrawable(getContext().getDrawable(id));
}
-
+
/**
* <p>Sets the vertical offset used for the auto-complete drop-down list.</p>
- *
+ *
* @param offset the vertical offset
*
* @attr ref android.R.styleable#ListPopupWindow_dropDownVerticalOffset
@@ -480,10 +482,10 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
public void setDropDownVerticalOffset(int offset) {
mPopup.setVerticalOffset(offset);
}
-
+
/**
* <p>Gets the vertical offset used for the auto-complete drop-down list.</p>
- *
+ *
* @return the vertical offset
*
* @attr ref android.R.styleable#ListPopupWindow_dropDownVerticalOffset
@@ -491,10 +493,10 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
public int getDropDownVerticalOffset() {
return mPopup.getVerticalOffset();
}
-
+
/**
* <p>Sets the horizontal offset used for the auto-complete drop-down list.</p>
- *
+ *
* @param offset the horizontal offset
*
* @attr ref android.R.styleable#ListPopupWindow_dropDownHorizontalOffset
@@ -502,10 +504,10 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
public void setDropDownHorizontalOffset(int offset) {
mPopup.setHorizontalOffset(offset);
}
-
+
/**
* <p>Gets the horizontal offset used for the auto-complete drop-down list.</p>
- *
+ *
* @return the horizontal offset
*
* @attr ref android.R.styleable#ListPopupWindow_dropDownHorizontalOffset
@@ -567,10 +569,10 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
public void setDropDownAlwaysVisible(boolean dropDownAlwaysVisible) {
mPopup.setDropDownAlwaysVisible(dropDownAlwaysVisible);
}
-
+
/**
* Checks whether the drop-down is dismissed when a suggestion is clicked.
- *
+ *
* @hide Pending API council approval
*/
public boolean isDropDownDismissedOnCompletion() {
@@ -578,17 +580,17 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
}
/**
- * Sets whether the drop-down is dismissed when a suggestion is clicked. This is
+ * Sets whether the drop-down is dismissed when a suggestion is clicked. This is
* true by default.
- *
+ *
* @param dropDownDismissedOnCompletion Whether to dismiss the drop-down.
- *
+ *
* @hide Pending API council approval
*/
public void setDropDownDismissedOnCompletion(boolean dropDownDismissedOnCompletion) {
mDropDownDismissedOnCompletion = dropDownDismissedOnCompletion;
}
-
+
/**
* <p>Returns the number of characters the user must type before the drop
* down list is shown.</p>
@@ -720,13 +722,13 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
/**
* <p>Changes the list of data used for auto completion. The provided list
* must be a filterable list adapter.</p>
- *
+ *
* <p>The caller is still responsible for managing any resources used by the adapter.
* Notably, when the AutoCompleteTextView is closed or released, the adapter is not notified.
* A common case is the use of {@link android.widget.CursorAdapter}, which
* contains a {@link android.database.Cursor} that must be closed. This can be done
- * automatically (see
- * {@link android.app.Activity#startManagingCursor(android.database.Cursor)
+ * automatically (see
+ * {@link android.app.Activity#startManagingCursor(android.database.Cursor)
* startManagingCursor()}),
* or by manually closing the cursor when the AutoCompleteTextView is dismissed.</p>
*
@@ -811,7 +813,7 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
if (mPopup.onKeyDown(keyCode, event)) {
return true;
}
-
+
if (!isPopupShowing()) {
switch(keyCode) {
case KeyEvent.KEYCODE_DPAD_DOWN:
@@ -924,18 +926,18 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
protected CharSequence convertSelectionToString(Object selectedItem) {
return mFilter.convertResultToString(selectedItem);
}
-
+
/**
- * <p>Clear the list selection. This may only be temporary, as user input will often bring
+ * <p>Clear the list selection. This may only be temporary, as user input will often bring
* it back.
*/
public void clearListSelection() {
mPopup.clearListSelection();
}
-
+
/**
* Set the position of the dropdown view selection.
- *
+ *
* @param position The position to move the selector to.
*/
public void setListSelection(int position) {
@@ -943,13 +945,13 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
}
/**
- * Get the position of the dropdown view selection, if there is one. Returns
+ * Get the position of the dropdown view selection, if there is one. Returns
* {@link ListView#INVALID_POSITION ListView.INVALID_POSITION} if there is no dropdown or if
* there is no selection.
- *
- * @return the position of the current selection, if there is one, or
+ *
+ * @return the position of the current selection, if there is one, or
* {@link ListView#INVALID_POSITION ListView.INVALID_POSITION} if not.
- *
+ *
* @see ListView#getSelectedItemPosition()
*/
public int getListSelection() {
@@ -1020,7 +1022,7 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
dismissDropDown();
}
}
-
+
/**
* Identifies whether the view is currently performing a text completion, so subclasses
* can decide whether to respond to text changed events.
@@ -1172,7 +1174,7 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
public void showDropDownAfterLayout() {
mPopup.postShow();
}
-
+
/**
* Ensures that the drop down is not obscuring the IME.
* @param visible whether the ime should be in front. If false, the ime is pushed to
@@ -1220,7 +1222,7 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
* Forces outside touches to be ignored. Normally if {@link #isDropDownAlwaysVisible()} is
* false, we allow outside touch to dismiss the dropdown. If this is set to true, then we
* ignore outside touch even when the drop down is not set to always visible.
- *
+ *
* @hide used only by SearchDialog
*/
public void setForceIgnoreOutsideTouch(boolean forceIgnoreOutsideTouch) {
@@ -1245,7 +1247,7 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
realCount++;
}
}
-
+
if (realCount != count) {
CompletionInfo[] tmp = new CompletionInfo[realCount];
System.arraycopy(completions, 0, tmp, 0, realCount);
@@ -1340,7 +1342,7 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
*/
CharSequence fixText(CharSequence invalidText);
}
-
+
/**
* Listener to respond to the AutoCompleteTextView's completion list being dismissed.
* @see AutoCompleteTextView#setOnDismissListener(OnDismissListener)