I am creating an App and it crashes when I click the button to increase the value in a text field by 1. I am very tired and maybe I am not looking at this correctly. This is a button click event.
I have placed everything in a while loop that will never end. Then the ifs will increase the value by 1 in the int and then store it into a string that will set the value to the text box. I will also be including a decrease button to the the reverse.
int SetUP = Integer.parseInt(findTxtComp().getText());
String SetUp;
SetUp = String.valueOf(SetUP);
int ChstSetLoop;
ChstSetLoop = 1;
while(ChstSetLoop == 1){
if(SetUp.equals("0")){
SetUP = 1;
SetUp = String.valueOf(SetUP);
findTxtComp().setText(SetUp);
}
if(SetUp.equals("1")){
SetUP = 2;
SetUp = String.valueOf(SetUP);
findTxtComp().setText(SetUp);
}
if(SetUp.equals("2")){
SetUP = 3;
SetUp = String.valueOf(SetUP);
findTxtComp().setText(SetUp);
}
if(SetUp.equals("3")){
SetUP = 4;
SetUp = String.valueOf(SetUP);
findTxtComp().setText(SetUp);
}
if(SetUp.equals("4")){
SetUP = 5;
SetUp = String.valueOf(SetUP);
findTxtComp().setText(SetUp);
SetUP = 0;
}
else{
}
}
Aucun commentaire:
Enregistrer un commentaire