1
How to make a condition in which it will jump 7 by 7 because I’m having to set it manually in hand, and if you have data on the defined ids, it will give error there would complicate . Below is an example of the code to which I need to decrease and make it always add 7 ,as long as there are items in listview:
if (id_item_titulo == 0 ||id_item_titulo == 7 || id_item_titulo == 14 || id_item_titulo == 21 || id_item_titulo == 28 || id_item_titulo == 35
|| id_item_titulo == 42 || id_item_titulo == 49 || id_item_titulo == 56 || id_item_titulo == 63
|| id_item_titulo == 70 || id_item_titulo == 77 || id_item_titulo == 85 || id_item_titulo == 92
|| id_item_titulo == 99 || id_item_titulo == 106 || id_item_titulo == 111 || id_item_titulo == 118
|| id_item_titulo == 125 || id_item_titulo == 132) {
}
In case it then goes to 14,21,28 and so goes 7 in 7 automatically ? I want to avoid setting the values of the IDS clicked.
– Diego Kappaun
He won’t "go" anywhere, but he’ll only get into
if
if the ID is multiple of 7, or zero. Example: http://ideone.com/OkRJvV– bfavaretto
I was intrigued by your question above, and I thought knowing this might help you:
id_item_titulo % 7
is a expression where%
is the operator, and what’s around him are the operandos. This expression returns a value (the rest of the division by 7), which is then compared to zero.– bfavaretto
Friend, arriving home I will try this idea, and I come back here to inform you whether I got it or not, I thank you already in advance.
– Diego Kappaun
Thanks, I put if (id_do_item % 2 == 0 || id_do_item % 2== 1 ) { //**** } and it worked : )
– Diego Kappaun
But @Diegokappaun, that you put does not jump 7 in 7!
– bfavaretto
The 7-in-7 was to do a single action of a particular item, only I put that new condition to take in all and decrease the size of the code. I had put a condition in the other class of when clicking on the blank space it did not open an Activity, while the others could normally, and already in the class that set this new condition, they could be even and odd, so I had no problem adding and updating .
– Diego Kappaun
But... but...
if (id_do_item % 2 == 0 || id_do_item % 2== 1 )
makes no sense! Any integer will always be even or odd. So you don’t even need theif
. @Diegokappaun– bfavaretto
I did tests and when I put multiple methods inside the IF with only the different condition, it runs only the item that of the rest 0 and I need it to be 0 and 1 for the other items to be changed smoothly, is that my way of creating the program was a little different .
– Diego Kappaun