title: OnclickListener in a checkbox (Android Studio)
body: <p>here is part of my code which includes the CheckBox(ChckBoxNo):</p>
  
  <pre><code>    final CheckBox ChckBoxNo = (CheckBox)promptsView.findViewById(R.id.ChkBoxNo);
  
                                    ChckBoxNo.setChecked(true);
  
                                     ChckBoxNo.setOnClickListener(new View.OnClickListener() {
                                         @Override
                                         public void onClick(View v) {
                                             if (ChckBoxNo.isChecked()) {
  
                                           ChckBoxNo.setChecked(false);
                                             }
                                             else if (!ChckBoxNo.isChecked())
                                             {
                                                 ChckBoxNo.setChecked(true);
                                             }
                                         }
                                     });
  </code></pre>
  
  <p>At the begining I set true for the isChecked() method on my checkbox , then I implement the onclicklistener on the checkbox.
  When I run the app the checkbox is Checked as I defined eralier , but when I click on the checkbox ,It's unchecked and then immidately checked again(I didnt clciked again on the checkbox! )
  What should I do in order to fix that,what wrong in my code ?
  Thanks!</p>