This repository was archived by the owner on Jul 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 444
setSelectedIndex crash #166
Copy link
Copy link
Open
Description
If the spinner uses a selected text formatter with a type, calling setSelectedIndex crashes:
java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Locale
...
at org.angmarch.views.NiceSpinner.setTextInternal(NiceSpinner.java:307)
at org.angmarch.views.NiceSpinner.setSelectedIndex(NiceSpinner.java:323)
Example:
val textFormatter: SpinnerTextFormatter<Locale> = SpinnerTextFormatter<Locale> {
locale -> SpannableString(locale.getDisplayName(defaultLocale))
}
view.locale_spinner.setSpinnerTextFormatter(textFormatter)
view.locale_spinner.setSelectedTextFormatter(textFormatter)
view.locale_spinner.attachDataSource(locales)
view.locale_spinner.selectedIndex = someIndexThe problem is setSelectedIndex calls setTextInternal(selectedTextFormatter.format(adapter.getItemInDataset(position)).toString()); which then calls setText(selectedTextFormatter.format(item)); but item is already a string and not the expected type.
Metadata
Metadata
Assignees
Labels
No labels