Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Well, we would need a bit more information to help you. However, I assume you are trying to use the <a href="http://developer.android.com/reference/android/widget/CompoundButton.OnCheckedChangeListener.html" rel="nofollow">OnCheckedChangeListener</a> which is implemented by your main Activity? If you are having trouble with referencing IDs, you can always just implement an individual lisenter on a specific element, for example:</p> <pre><code>checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if ( isChecked ) { prevChecked = true; Log.d("CHECKBOX","Previously Checked = "+prevChecked); }else{ prevChecked = false; Log.d("CHECKBOX","Previously Checked = "+prevChecked); } } }); </code></pre> <p>Where prevChecked is a global variable. I have also thrown in a couple of Log's so you can output the information to the LogCat. Hope that helps in your debugging.</p> <p><em><strong></em>**<em>*</em>**</strong> EDIT TO SUIT YOUR ADDED COMMENT <strong><em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>***</strong></p> <p>Have you tried to swap your switch statement with and if statement. e.g.</p> <pre><code>if(v.getId() == R.id.checkbox1){ }else if(v.getId() == R.id.checkbox2){ } </code></pre> <p>Additionally, what interface is <code>onCheckboxClicked(View v)</code>, is this a custom element? How have you defined your check boxes in your R.layout.activity_main.xml? If you have a checkbox interface you need to implement a listener like my example above. I can't see that your setting a listener anywhere, nor are you implementing it in your activity. For example:</p> <pre><code>public class MainActivity extends Activity implements onCheckChangedListener { </code></pre> <p>But as far as I can tell, unless it is a custom element it doesn't make any sense that <code>public void onCheckboxClicked(View v)</code> Even get's called. This <a href="http://vimaltuts.com/androids/android-checkbox-example" rel="nofollow">example</a> might help.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload