java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference
at android.widget.ArrayAdapter.getCount(ArrayAdapter.java:344)
at com.tiper.MaterialSpinner$DropDownAdapter.getCount(MaterialSpinner.kt:775)
at com.tiper.MaterialSpinner.setSelection(MaterialSpinner.kt:131)
I get the list that would be used for the spinner from the server, and I was setting it to null when no connection or connection error. Now I set to an empty array and it works.
Maybe it's not a bug, but it took me a while to figure out that the problem was the null adapter. Maybe you can throw a different exception? Or clear it anyway even if it has no adapter
When I try to clear the spinnerSelection.
And then I get:
I get the list that would be used for the spinner from the server, and I was setting it to
null
when no connection or connection error. Now I set to anempty array
and it works.Maybe it's not a bug, but it took me a while to figure out that the problem was the
null
adapter. Maybe you can throw a different exception? Or clear it anyway even if it has no adapter