代码示例:
private int _spinnerPreviousPosition = 0; private Spinner _spinner;
_spinner = findViewById(R.id.spinner); _spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView> adapterView, View view, int position, long id) { if (position == _spinnerPreviousPosition){ return; }else { _spinnerPreviousPosition = position; // add code here for actions to take when re-selecting spinner item } }
@Override public void onNothingSelected(AdapterView> adapterView) {
} });