Today, an error occurred while implementing the spinner control:
Cannot cast from View to Spinner. As shown in figure:
Private Spinner Spinner01;
spinner01= (Spinner) Findviewbyid (R.ID.SPINNER01);
The reason for the search on the Internet is the problem of importing the package, after checking the code found that it is really the wrong package, as shown:
The reason is that the Java file class name in my own project package Nyist.daylight is also spinner, and the correct one to import should be the Android.widget package.
The solution is to choose Spinner-android.widget,
Private Android.widget.Spinner Spinner01;
spinner01= (Android.widget.Spinner) Findviewbyid (R.ID.SPINNER01);
This allows the program to run normally.
Summary: When you create a new project, it's best not to have the same name and name as the class in Android, or to import the correct package when you're in the package, so you can avoid this error.