Why doesn't the Spinner class offer generics?
The answer is simply because the Android AdapterView widget can be used to store various types of objects. The purpose of the adapter is to provide a consistent view of these objects.
If you add a common option in the interface
), you will record the type of baseline data collection, which goes against the whole adapter thing.
The idea is that the adapter view doesn't need to know about the underlying data behind the adapter, so it doesn't need to restrict its data type.
However, you can specialize an interface
with a specific type (or generic segment) in your own implementation
, and then access the data through an adapter, not an AdapterView:
source to share