You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
java.lang.ArrayIndexOutOfBoundsException: length=12; index=-1
at java.util.ArrayList.get(ArrayList.java:310)
at com.bruce.pickerview.LoopView.onDraw(LoopView.java:258)
The issue is cause by the looping
if (templateItem < 0) {
templateItem = templateItem + mDataList.size();
}
if (templateItem > mDataList.size() - 1) {
templateItem = templateItem - mDataList.size();
}
// at this point the templateItem could still be a negative number if the items are really small say 2 and the number of items to be displayed is say 10, for the templateItem to be positive this would need to be looped 5 times.
itemCount[count] = (String) mDataList.get(templateItem);
// i fixed the error by adding
// if (templateItem < 0) continue; just before the itemCount[count] = ...
//It should be corrected as
if (templateItem < 0) continue; // to prevent futher looping after the first loop
itemCount[count] = (String) mDataList.get(templateItem);
The text was updated successfully, but these errors were encountered:
java.lang.ArrayIndexOutOfBoundsException: length=12; index=-1
at java.util.ArrayList.get(ArrayList.java:310)
at com.bruce.pickerview.LoopView.onDraw(LoopView.java:258)
The issue is cause by the looping
if (templateItem < 0) {
templateItem = templateItem + mDataList.size();
}
if (templateItem > mDataList.size() - 1) {
templateItem = templateItem - mDataList.size();
}
// at this point the templateItem could still be a negative number if the items are really small say 2 and the number of items to be displayed is say 10, for the templateItem to be positive this would need to be looped 5 times.
itemCount[count] = (String) mDataList.get(templateItem);
// i fixed the error by adding
// if (templateItem < 0) continue; just before the itemCount[count] = ...
//It should be corrected as
if (templateItem < 0) continue; // to prevent futher looping after the first loop
itemCount[count] = (String) mDataList.get(templateItem);
The text was updated successfully, but these errors were encountered: