Thursday, 22 August 2013

Switch Statement not working?

Switch Statement not working?

I know im doing something wrong but I really cant figure out what it is,
What I am trying to accomplish is have the switch statement know if One
ImageView is gone then let me know one is gone. and move to number 2 if
two image views are gone then move to number three. It works with number
one but doesn't move two number two if a write this code here
WORKING CODE
if (numOne == ImageView.GONE) {
Toast.makeText(.......).show()
}
if (numTwo == ImageView.GONE + 2) {
Toast.makeText(.......).show()
}
I understand that it wont flow through the if statement if the first
statement is true, and that's why I need a switch statement so it goes
through all of them
here is my SWITCH STATEMENT
int numOne = ImageView.GONE;
int numTwo = ImageView.GONE + 2;
int numThree = ImageView.GONE + 3;
int numFour = ImageView.GONE + 4;
int numFive = ImageView.GONE + 5;
int numSix = ImageView.GONE + 6;
int numSeven = ImageView.GONE + 7;
int numEight = ImageView.GONE + 8;
int numNine = ImageView.GONE + 9;
int numTen = ImageView.GONE + 10;
switch (iGone = 0){ //tried using switch (ImageView.GONE) didn't work
case 1:
if (numOne == ImageView.GONE) {
Toast.makeText(this, "One Gone Now Put two in the
basket", Toast.LENGTH_LONG).show();
};
break;
case 2:
if (numTwo == ImageView.GONE + 2){
Toast.makeText(this, "Two Gone Now Put Three in the basket",
Toast.LENGTH_LONG).show();
};
break;
case 3:
if (numThree == ImageView.GONE + 3) {
Toast.makeText(this, "Three Gone Now Put Four in the
basket", Toast.LENGTH_LONG).show();
}
break;
case 4:
if (numFour == ImageView.GONE + 4){
Toast.makeText(this, "Four Gone Now Put Five in the basket",
Toast.LENGTH_LONG).show();
}
break;
case 5:
if (numFive == ImageView.GONE + 5) {
Toast.makeText(this, "Five Gone Now Put two in the basket",
Toast.LENGTH_LONG).show();
}
break;
}
again what I am trying to accomplish is When one ImageView is gone let me
know and tell me that one is gone then move on two starting from 0 and
counting up to TWO, then once you finish number two start at 0 again and
count to number 3 ect......

No comments:

Post a Comment