diff options
| author | Jin Cao <jinyan@google.com> | 2014-11-10 11:06:12 -0800 |
|---|---|---|
| committer | Jin Cao <jinyan@google.com> | 2014-11-10 11:06:12 -0800 |
| commit | 939f5f1fb5b2d851a5b36fc9908c2c6420b193ae (patch) | |
| tree | 48677cefab56195583ccf5f4a7cb1092d3e090e2 | |
| parent | d525772ac3de152c946c2b7486ff759b8a45f9f2 (diff) | |
| download | android_frameworks_opt_chips-939f5f1fb5b2d851a5b36fc9908c2c6420b193ae.tar.gz android_frameworks_opt_chips-939f5f1fb5b2d851a5b36fc9908c2c6420b193ae.tar.bz2 android_frameworks_opt_chips-939f5f1fb5b2d851a5b36fc9908c2c6420b193ae.zip | |
Auto dismiss popups when touches happen outside the popup window
b/18218445
Change-Id: I9f5d0b2bfbc023c1f77967cf14de45e769bdd543
| -rw-r--r-- | src/com/android/ex/chips/RecipientEditTextView.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/com/android/ex/chips/RecipientEditTextView.java b/src/com/android/ex/chips/RecipientEditTextView.java index 4adaf7a..2e6b94b 100644 --- a/src/com/android/ex/chips/RecipientEditTextView.java +++ b/src/com/android/ex/chips/RecipientEditTextView.java @@ -86,6 +86,7 @@ import android.widget.ListAdapter; import android.widget.ListPopupWindow; import android.widget.ListView; import android.widget.MultiAutoCompleteTextView; +import android.widget.PopupWindow; import android.widget.ScrollView; import android.widget.TextView; @@ -266,9 +267,9 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements sSelectedTextColor = context.getResources().getColor(android.R.color.white); } mAlternatesPopup = new ListPopupWindow(context); - mAlternatesPopup.setBackgroundDrawable(null); + setupPopupWindow(mAlternatesPopup); mAddressPopup = new ListPopupWindow(context); - mAddressPopup.setBackgroundDrawable(null); + setupPopupWindow(mAddressPopup); mCopyDialog = new Dialog(context); mAlternatesListener = new OnItemClickListener() { @Override @@ -304,6 +305,16 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements setDropdownChipLayouter(new DropdownChipLayouter(LayoutInflater.from(context), context)); } + private void setupPopupWindow(ListPopupWindow popup) { + popup.setModal(true); + popup.setOnDismissListener(new PopupWindow.OnDismissListener() { + @Override + public void onDismiss() { + clearSelectedChip(); + } + }); + } + @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); |
