I am using a spinner with a custom adapter in my application. And depends on the selected item I want to call an API service. But API is not calling if I reselect the same item that is already currently selected. The element in the first position is hint text (Choose Item). So I have not called service on first item selection
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if (isNetworkAvailable()) {
progressBar.setVisibility(View.VISIBLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
try {
if (position == 0) {
progressBar.setVisibility(View.GONE);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
return;
} else {
changePath(position, arrayitem.get(position));
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});