Skip to content

Commit 2db8b0c

Browse files
drchenafohrman
authored andcommitted
[TextField] Link OnItemSelectedListener of AutoCompleteTextView with the actual drop-down list
Framework has no default implementation of how or when OnItemSelectedListener will be called. We need to link it with the actual ListPopupWindow we are going to show. Resolves #1804 PiperOrigin-RevId: 449725174
1 parent 73cb1b6 commit 2db8b0c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/java/com/google/android/material/textfield/MaterialAutoCompleteTextView.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import android.view.accessibility.AccessibilityManager;
4242
import android.widget.AdapterView;
4343
import android.widget.AdapterView.OnItemClickListener;
44+
import android.widget.AdapterView.OnItemSelectedListener;
4445
import android.widget.ArrayAdapter;
4546
import android.widget.Filterable;
4647
import android.widget.ListAdapter;
@@ -192,6 +193,12 @@ public void setRawInputType(int type) {
192193
onInputTypeChanged();
193194
}
194195

196+
@Override
197+
public void setOnItemSelectedListener(@Nullable OnItemSelectedListener listener) {
198+
super.setOnItemSelectedListener(listener);
199+
modalListPopup.setOnItemSelectedListener(getOnItemSelectedListener());
200+
}
201+
195202
/**
196203
* Sets the simple string items of auto-completion with the given string array resource. This
197204
* method will create a default {@link ArrayAdapter} with a default item layout specified by

0 commit comments

Comments
 (0)