summaryrefslogtreecommitdiff
path: root/core/java/android/widget/AutoCompleteTextView.java
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-01-15 16:12:10 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-01-15 16:12:10 -0800
commit9266c558bf1d21ff647525ff99f7dadbca417309 (patch)
tree1630b1ba80f4793caf39d865528e662bdb1037fe /core/java/android/widget/AutoCompleteTextView.java
parentb798689749c64baba81f02e10cf2157c747d6b46 (diff)
auto import from //branches/cupcake/...@126645
Diffstat (limited to 'core/java/android/widget/AutoCompleteTextView.java')
-rw-r--r--core/java/android/widget/AutoCompleteTextView.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/core/java/android/widget/AutoCompleteTextView.java b/core/java/android/widget/AutoCompleteTextView.java
index 1591791c4fdb..024b663d8308 100644
--- a/core/java/android/widget/AutoCompleteTextView.java
+++ b/core/java/android/widget/AutoCompleteTextView.java
@@ -514,8 +514,48 @@ 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
+ * it back.
+ */
+ public void clearListSelection() {
+ if (mDropDownList != null) {
+ mDropDownList.hideSelector();
+ mDropDownList.requestLayout();
+ }
+ }
+
+ /**
+ * Set the position of the dropdown view selection.
+ *
+ * @param position The position to move the selector to.
+ */
+ public void setListSelection(int position) {
+ if (mPopup.isShowing() && (mDropDownList != null)) {
+ mDropDownList.setSelection(position);
+ // ListView.setSelection() will call requestLayout()
+ }
+ }
/**
+ * 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
+ * {@link ListView#INVALID_POSITION ListView.INVALID_POSITION} if not.
+ *
+ * @see ListView#getSelectedItemPosition()
+ */
+ public int getListSelection() {
+ if (mPopup.isShowing() && (mDropDownList != null)) {
+ return mDropDownList.getSelectedItemPosition();
+ }
+ return ListView.INVALID_POSITION;
+ }
+
+ /**
* <p>Starts filtering the content of the drop down list. The filtering
* pattern is the content of the edit box. Subclasses should override this
* method to filter with a different pattern, for instance a substring of