I did similar things before, I used count value. Using the parent adapter object is incomplete, as this may be a problem when updating the view or getView() .
Therefore, I recommend using an array of counters.
First, define the count array in the adapter globally.
private int isInitializedView[];
And then initialize it to getView ().
isInitializedView[position] = 0;
In the selection listener, do what you want if it is already initialized.
holder.mySpinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { isInitializedView[position]++; if(isInitializedView[position] > 1) {
(Note that isInitializedView[position]++; may appear after the if() procedure and only trigger event when this value >0 This is your choice.)
Seongeun so
source share