title: How to disable onItemSelectedListener to be invoked when setting selected item by code
body: <p>Just wondering how you handle the following problem: a result is calculated depending on two spinners' selected items. To handle the UI things, i.e. a user picks a new item in one of the spinners, I install a listener using <code>setOnItemSelectedListener</code> for the spinner in my <code>onCreate()</code> method of the activity.</p>
  
  <p>Now: that works, of course, fine. The listener's work is to trigger a new calculation of the result.</p>
  
  <p>The problem: because I intercept <code>onPause()</code> <code>onResume()</code> to save/restore the last state, I got a method that <strong>sets</strong> these two spinners' selected item programmatically like in here:</p>
  
  <pre><code>startSpinner.setSelection(pStart);
  destSpinner.setSelection(pDest);
  </code></pre>
  
  <p>These two calls invoke the listeners, too! My calculation method for the result plus the notification of a new result set is invoked twice here!</p>
  
  <p>A stupid direct approach for this would be to have a boolean variable <strong>disabling</strong> whatever the listener does inside, setting it before setting the selected items and resetting it afterwards.
  Okay. But is there a better method??</p>
  
  <p>I don't want listeners to be called by code - actions, only by user actions! :-(</p>
  
  <p>How do you do it?
  Thanks!</p>