title: switch button works on the second click - Android
body: <p>I added a switch button to my app and created a setOnCheckChangeListener the will pop up toast message..</p>
  
  <p>But it works only after the second click.</p>
  
  <p>Any ideas?</p>
  
  <p><strong>MainActivity:</strong></p>
  
  <pre><code>    public void checkSwitch (View view)
  {
      addBeeps.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
              if (isChecked)
              {
                  beeps = true;
                  Toast.makeText(MainActivity.this,"beeps is True",Toast.LENGTH_LONG).show();
              }else
              {
                  beeps = false;
                  Toast.makeText(MainActivity.this,"beeps is False",Toast.LENGTH_LONG).show();
              }
          }
      });
  
  }
  </code></pre>