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
If the MaterialListBox has an empty placeholder, the following code
publicintgetIndex(Tvalue) {
intcount = getItemCount();
for (inti = 0; i < count; i++) {
if (Objects.equals(getValue(i), value)) {
returni;
}
}
return -1;
}
throws an IndexOutOfBoundsException at getValue(i).
The reason is that the getItemCount() will also count the empty placeholder as an item, so when calling getValue(i) in the for loop, it will then call getValueInternal(index + getIndexOffset()), which will, in the last element, try to get a position = count.
Example:
If the list has no items, count will be 1 and getValue(0) will translate to getValueInternal(1). Since there is only one element (index 0), it will throw the exception.
The text was updated successfully, but these errors were encountered:
If the MaterialListBox has an empty placeholder, the following code
throws an
IndexOutOfBoundsException
atgetValue(i)
.The reason is that the
getItemCount()
will also count the empty placeholder as an item, so when callinggetValue(i)
in the for loop, it will then callgetValueInternal(index + getIndexOffset())
, which will, in the last element, try to get a position = count.Example:
If the list has no items, count will be 1 and
getValue(0)
will translate togetValueInternal(1)
. Since there is only one element (index 0), it will throw the exception.The text was updated successfully, but these errors were encountered: