Monday, 12 October 2015

How to avoid onItemSelected calls during initialization


   Here I am going to explain how to keep onItemSelected from firing off on a newly instantiated Spinner


       int check = 0;
       Spinner.setOnItemSelectedListener(new OnItemSelectedListener() 
        {
@Override
public void onItemSelected(AdapterView<?> parentView,
View selectedItemView, int position, long id)

{
check check + 1;
if (check > 1) 
                              {

new LongOperation().execute("");


}
}

@Override
public void onNothingSelected(AdapterView<?> parentView) {

}

});