Hi sorry for the simple question but i must be doing something wrong,
I have 12 check box's if a check box is selected a int total needs to be incremented by a fixed value (depending on the box) and displayed in a textView
when i check a box it does not show the value it's suppose to - refurbCost is initalized at 0 in the constructor and is displayed as 0 when no box is selected
when i select new kitchen is shows as 21300 instead of 3000
what am i doing wrong - p.s i know the code probably isn't great practice im still pretty new at android developing
code
public void onClick(View v) {
boolean checked = ((CheckBox) v).isChecked() ;
switch (v.getId()){
case R.id.centralHeating:
if(checked) {
refurbCost += 2750;
}
case R.id.newKitchen:
if(checked) {
refurbCost += 3000;
}
case R.id.newBathroom:
if(checked) {
refurbCost += 1000 ;
}
case R.id.reWire:
if(checked) {
refurbCost += 2500;
}
case R.id.windowDoors :
if(checked) {
refurbCost += 3000;
}
case R.id.stairsBanisters:
if(checked) {
refurbCost += 2000;
}
case R.id.carpets:
if(checked) {
refurbCost += 2000;
}
case R.id.garden:
if(checked) {
refurbCost += 1000;
}
case R.id.wallCeiling:
if(checked) {
refurbCost += 1000;
}
case R.id.decoration:
if(checked) {
refurbCost += 1200;
}
case R.id.alarmSys:
if(checked) {
refurbCost += 600;
}
case R.id.fireSafety:
if(checked) {
refurbCost += 4000;
}
refurbTotal.setText(""+refurbCost);
}
Aucun commentaire:
Enregistrer un commentaire