Reputation: 994
I'm developing a simple Android app in Visual Studio using .NET and Xamarin. Everything is going well except that I seem to missing certain UI elements. Specifically, I'm missing the Spinner class. Is there something simple I should have done when setting up Visual Studio 2019 for Android Xamarin development that would have made these available?
Here is the error when I try to include a Spinner in the XAML file:
The type 'Spinner' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.
Now it may be that Android widgets are not available in Xamarin-- if that's the case, someone please set me straight. I can't confirm with my research, though, whether that's the case.
Here is all the version info for my Visual Studio build, Xamarin, etc. I'm building for Android 9.0.
Microsoft Visual Studio Community 2019
Version 16.4.1
VisualStudio.16.Release/16.4.1+29609.76
Microsoft .NET Framework
Version 4.7.03056
Installed Version: Community
Azure App Service Tools v3.0.0 16.4.457.38025
Azure App Service Tools v3.0.0
C# Tools 3.4.1-beta4-19607-02+52d275c4f82f329a9732b078c7f7fa0e45cd3e84
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.
Extensibility Message Bus 1.2.0 (d16-2@8b56e20)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.
IntelliCode Extension 1.0
IntelliCode Visual Studio Extension Detailed Info
Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers
Mono Debugging for Visual Studio 16.5.23 (1b51e8c)
Support for debugging Mono processes with Visual Studio.
NuGet Package Manager 5.4.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/
ProjectServicesPackage Extension 1.0
ProjectServicesPackage Visual Studio Extension Detailed Info
Visual Basic Tools 3.4.1-beta4-19607-02+52d275c4f82f329a9732b078c7f7fa0e45cd3e84
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Visual F# Tools 10.4 for F# 4.6 16.4.0-beta.19556.5+e7597deb7042710a7142bdccabd6f92b0840d354
Microsoft Visual F# Tools 10.4 for F# 4.6
Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio
VisualStudio.DeviceLog 1.0
Information about my package
VisualStudio.Foo 1.0
Information about my package
VisualStudio.Mac 1.0
Mac Extension for Visual Studio
Xamarin 16.4.000.306 (d16-4@564b8d0)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.
Xamarin Designer 16.4.0.464 (remotes/origin/d16-4@4abf337c3)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.
Xamarin Templates 16.4.25 (579ee62)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.
Xamarin.Android SDK 10.1.1.0 (d16-4/f2c9364)
Xamarin.Android Reference Assemblies and MSBuild support.
Mono: bef1e63
Java.Interop: xamarin/java.interop/d16-4@c4e569f
ProGuard: xamarin/proguard/master@905836d
SQLite: xamarin/sqlite/3.28.0@46204c4
Xamarin.Android Tools: xamarin/xamarin-android-tools/master@9f4ed4b
Xamarin.iOS and Xamarin.Mac SDK 13.8.3.0 (0d8fe21)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
Upvotes: 1
Views: 981
Reputation: 7455
Welcome to Xamarin!
If you want to create a pure Xamarin.Android application (and use widgets like Spinner, etc) you have to create an Android App by choosing the option in red in the image below in Visual Studio 2019:
There you will have access to most, if not all the widgets that Android has to offer. Refer to Xamarin docu for more details.
To create a Spinner with Xamarin.Android, you can also find a tutorial in the Xamarin docu.
Now, back to your question and the error you get:
To me it looks like you created a Xamarin.Forms solution and there you are trying to implement a Spinner (i see this from the error you got, and since you are speaking of XAML which is only available for Xamarin.Forms applications!). If this is your case, you should know that Spinner is not defined in Xamarin.Forms!
If you really want to create a Xamarin.Forms Application (in case you really want to go Cross Platform!) you can still use the Spinner: again, Xamarin docu has some information on how to use Native views in Xamarin.Forms.
On the other hand, if you really want to use Xamarin.Forms, and want to share as much code as possible, you should take a look at Picker.
Upvotes: 2
Reputation: 133
You have to re/install the NuGet packages for the used support libraries.
Here is a list of all available libraries: https://www.nuget.org/packages?q=Xamarin+support
You can also find them in the NuGet Package Manager in Visual Studio
Upvotes: 2