这是填充我的微调器的代码。
编码:
String[] rcs = new String[review_cycles.length];
for (int i = 0; i < review_cycles.length; i++)
rcs[i] = review_cycles[i].ReviewCycleName;
ArrayAdapter<String> rc_spinnerAdapter = new ArrayAdapter<String>(
ActivityManagementReview.this,
R.layout.simple_spinner_item,
rcs);
sp_review_cycle.setAdapter(rc_spinnerAdapter);
sp_review_cycle.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
DtoMrReviewCycleVersion selected_review_cycle_version = review_cycles[position];
if (selected_review_cycle_version != latest_review_cycle_version) {
latest_review_cycle_version = selected_review_cycle_version;
int mr_version_id = latest_review_cycle_version.MrdVersionId;
_URL_version = _url_base + "MrVersion/" + Integer.toString(mr_version_id);
new GetMrVersionInfoAsyncTask().execute();
}
}
@Override
public void onNothingSelected(AdapterView<?> parentView) {
return;
}
});
当我从微调器中选择一个值时,代码会执行两次。一旦我做出选择,然后立即执行,列表中的第一项将再次执行,使我回到开始的位置。
我怎样才能防止这种情况发生?
谢谢。