I have been sitting whole day with this problem:
I have a String array.After parsing String line
str3.split("\\n"));
Then I want to make it display with Next/Previous buttons.
String text = null;
if (rotation){
if (count < fullString.length) {
for (int i = count; i <= fullString.length - 1; i++) {
text = fullString[i];
++count;
if (text.trim().length() > 0 & !text.isEmpty()){
return text;
}
}
}
}
if (!rotation) {
if (count > 0) {
for (int i = count ; i >= 0; i--) {
text = fullString[i - 1];
--count;
if (text.trim().length() > 0 & !text.isEmpty()){
return text;
}
}
}
}
It woks, but need to press button twise (If press "Next" after that I should press "Previous" twise). I know, this is the silly question, but I can't find out the problem.
fullStringin the code may go out of bounds (the last iteration is havingi=0and you use indexi-1.