Skip to content

Commit 89bc863

Browse files
adampAndroid (Google) Code Review
authored andcommitted
Merge "Add an OnDismissListener to AutoCompleteTextView" into jb-mr1-dev
2 parents f4247c2 + 780c491 commit 89bc863

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

api/current.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27677,6 +27677,7 @@ package android.widget {
2767727677
method public void setDropDownVerticalOffset(int);
2767827678
method public void setDropDownWidth(int);
2767927679
method public void setListSelection(int);
27680+
method public void setOnDismissListener(android.widget.AutoCompleteTextView.OnDismissListener);
2768027681
method public void setOnItemClickListener(android.widget.AdapterView.OnItemClickListener);
2768127682
method public void setOnItemSelectedListener(android.widget.AdapterView.OnItemSelectedListener);
2768227683
method public void setText(java.lang.CharSequence, boolean);
@@ -27685,6 +27686,10 @@ package android.widget {
2768527686
method public void showDropDown();
2768627687
}
2768727688

27689+
public static abstract interface AutoCompleteTextView.OnDismissListener {
27690+
method public abstract void onDismiss();
27691+
}
27692+
2768827693
public static abstract interface AutoCompleteTextView.Validator {
2768927694
method public abstract java.lang.CharSequence fixText(java.lang.CharSequence);
2769027695
method public abstract boolean isValid(java.lang.CharSequence);

core/java/android/widget/AutoCompleteTextView.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package android.widget;
1818

19+
import android.app.SearchManager.OnDismissListener;
1920
import android.content.Context;
2021
import android.content.res.TypedArray;
2122
import android.database.DataSetObserver;
@@ -578,6 +579,23 @@ public AdapterView.OnItemSelectedListener getOnItemSelectedListener() {
578579
return mItemSelectedListener;
579580
}
580581

582+
/**
583+
* Set a listener that will be invoked whenever the AutoCompleteTextView's
584+
* list of completions is dismissed.
585+
* @param dismissListener Listener to invoke when completions are dismissed
586+
*/
587+
public void setOnDismissListener(final OnDismissListener dismissListener) {
588+
PopupWindow.OnDismissListener wrappedListener = null;
589+
if (dismissListener != null) {
590+
wrappedListener = new PopupWindow.OnDismissListener() {
591+
@Override public void onDismiss() {
592+
dismissListener.onDismiss();
593+
}
594+
};
595+
}
596+
mPopup.setOnDismissListener(wrappedListener);
597+
}
598+
581599
/**
582600
* <p>Returns a filterable list adapter used for auto completion.</p>
583601
*
@@ -1206,6 +1224,19 @@ public interface Validator {
12061224
CharSequence fixText(CharSequence invalidText);
12071225
}
12081226

1227+
/**
1228+
* Listener to respond to the AutoCompleteTextView's completion list being dismissed.
1229+
* @see AutoCompleteTextView#setOnDismissListener(OnDismissListener)
1230+
*/
1231+
public interface OnDismissListener {
1232+
/**
1233+
* This method will be invoked whenever the AutoCompleteTextView's list
1234+
* of completion options has been dismissed and is no longer available
1235+
* for user interaction.
1236+
*/
1237+
void onDismiss();
1238+
}
1239+
12091240
/**
12101241
* Allows us a private hook into the on click event without preventing users from setting
12111242
* their own click listener.

0 commit comments

Comments
 (0)