title: if statement allowing code to run when shouldnt
body: <p>Not sure why this is happening in my code as far as I can see it should be fine, though I have been at this all day.</p>
  
  <p>My problem is that I have a count that increments when a checkbox is selected or decreases when unchecked with a maximum of 4 choices allowed with an alert saying you cannot choose a 5th one.</p>
  
  <p>Choices 1 - 3 work fine - I output my variable to log cat and it goes up and down fine yet once I press the fourth choice and I press the 5th it allows it where I have said <code>premCount&lt;=4</code>.</p>
  
  <p>The alert shows on 6th press but allows the user to dismiss then select it again, and this continues when it shouldn't.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public void handlePremCheckboxClick(View v){
      CheckBox tmpChkBox = (CheckBox) findViewById(v.getId());
      if (premCounter&lt;=4){ &lt;---this part is allowing 5, 6, 7, etc presses through
          if(tmpChkBox.isChecked())
          {
              tmpChkBox.setBackgroundColor(Color.parseColor("#ff33b5e5"));
              premCounter++;
          }
          if(tmpChkBox.isChecked()== false)
          {
              tmpChkBox.setBackgroundColor(Color.TRANSPARENT);
              premCounter--;
          }
      }else if(premCounter &gt;4) {
          tmpChkBox.setChecked(false);
          tmpChkBox.setBackgroundColor(Color.TRANSPARENT);
          premCounter--;
  
          AlertDialog.Builder alert = new AlertDialog.Builder(this);
          alert.setTitle("Max Teams Reached")
          .setMessage("You have selected the max of 4 Premiership teams")
          .setPositiveButton("OK", null)
          .show(); 
      }   
      System.out.println(premCounter);
  
  }
  </code></pre>
  
  <p>logcat:</p>
  
  <pre><code>10-18 17:10:58.859: D/OpenGLRenderer(25923): Enabling debug mode 0
  10-18 17:11:06.146: D/dalvikvm(25923): GC_FOR_ALLOC freed 125K, 2% free 9286K/9448K, paused 17ms, total 17ms
  10-18 17:11:06.377: W/IInputConnectionWrapper(25923): finishComposingText on inactive InputConnection
  10-18 17:11:07.258: I/System.out(25923): 1
  10-18 17:11:07.488: I/System.out(25923): 2
  10-18 17:11:07.748: I/System.out(25923): 3
  10-18 17:11:08.039: I/System.out(25923): 2
  10-18 17:11:08.689: I/System.out(25923): 3
  10-18 17:11:08.939: I/System.out(25923): 4
  10-18 17:11:09.240: I/System.out(25923): 5
  10-18 17:11:09.550: I/System.out(25923): 4
  10-18 17:11:10.461: I/System.out(25923): 5
  10-18 17:11:10.801: I/System.out(25923): 4
  10-18 17:11:11.843: I/System.out(25923): 5
  10-18 17:11:12.483: I/System.out(25923): 4
  10-18 17:11:13.444: I/System.out(25923): 5
  10-18 17:11:13.695: I/System.out(25923): 4
  10-18 17:11:14.706: I/System.out(25923): 5
  10-18 17:11:15.086: I/System.out(25923): 4
  10-18 17:11:16.217: I/System.out(25923): 5
  </code></pre>