So I have some check boxes in my app and I want to change an array string to a set of null's and 1's depending on if the box is checked or not. I currently have this code:
public void SendSearch(View view) {
String [] searchArray = new String[18];
if (checkBoxCocktail.isChecked()){
searchArray[8]="1";
}
}
However when I call the method the app restarts. I'm pretty sure my above code is correct, I think my problem might lie with this method earlier which checks and unchecks the boxes when an imageview is clicked:
public void CheckCocktail(View view) {
checkBoxCocktail =(CheckBox) findViewById(R.id.checkBoxCocktail);
if (checkBoxCocktail.isChecked()) {
checkBoxCocktail.setChecked(false);
} else {
checkBoxCocktail.setChecked(true);
}
}
I just cant work out why it doesn't work, there is no logcat error when clicking the button the app just restarts. It doesn't matter if the checkbox is checked or not the app crashes regardless.
Aucun commentaire:
Enregistrer un commentaire