Xamarin AndroidX RecyclerView 适配器
Xamarin AndroidX RecyclerView Adapter
嗨,我是 Xamarin Android 开发的新手,我已经成功地将我的应用程序迁移到 AndroidX,没有任何错误,但是当我添加 RecyclerView 适配器时,它给了我一堆错误。任何帮助深表感谢。谢谢
重现步骤:
- 在 Nuget 中添加了 Xamarin AndroidX 包
- 添加 RecyclerView 适配器
这是我的包裹:
<PackageReference Include="Xamarin.Android.Support.Design" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Android.Support.Core.Utils" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Android.Support.CustomTabs" Version="28.0.0.3" />
<PackageReference Include="Xamarin.AndroidX.Annotation">
<Version>1.1.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.AppCompat">
<Version>1.1.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.Browser">
<Version>1.2.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.CardView">
<Version>1.0.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData">
<Version>2.2.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.Media">
<Version>1.1.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.MediaRouter">
<Version>1.1.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.Migration">
<Version>1.0.2</Version>
</PackageReference>
<PackageReference Include="Xamarin.Essentials" Version="1.3.1" />
<PackageReference Include="Xamarin.Firebase.Auth">
<Version>60.1142.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.Firebase.Common">
<Version>60.1142.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.Firebase.Database">
<Version>60.1142.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.Google.Android.Material">
<Version>1.0.0</Version>
</PackageReference>
这是我的错误:
Severity Code Description Project File Line Suppression State
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 30 Active
Error CS1503 Argument 2: cannot convert from 'method group' to 'Action<StorelistAdapterClickEventArgs>' ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 30 Active
Error CS0246 The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 1 Active
Error CS0246 The type or namespace name 'Android' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 3 Active
Error CS0246 The type or namespace name 'Android' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 4 Active
Error CS0246 The type or namespace name 'Android' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 5 Active
Error CS0246 The type or namespace name 'RecyclerView' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 9 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 11 Active
Error CS0246 The type or namespace name 'EventHandler<>' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 11 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 11 Active
Error CS0518 Predefined type 'System.Void' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 11 Active
Error CS0518 Predefined type 'System.Void' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 11 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 12 Active
Error CS0246 The type or namespace name 'EventHandler<>' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 12 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 12 Active
Error CS0518 Predefined type 'System.Void' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 12 Active
Error CS0518 Predefined type 'System.Void' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 12 Active
Error CS0518 Predefined type 'System.String' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 13 Active
Error CS0518 Predefined type 'System.Void' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 15 Active
Error CS0518 Predefined type 'System.String' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 15 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 21 Active
Error CS0246 The type or namespace name 'RecyclerView' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 21 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 21 Active
Error CS0246 The type or namespace name 'ViewGroup' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 21 Active
Error CS0518 Predefined type 'System.Int32' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 21 Active
Error CS0518 Predefined type 'System.Void' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 35 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 35 Active
Error CS0246 The type or namespace name 'RecyclerView' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 35 Active
Error CS0518 Predefined type 'System.Int32' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 35 Active
Error CS0518 Predefined type 'System.Int32' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 44 Active
Error CS0115 'StorelistAdapter.ItemCount': no suitable method found to override ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 44 Active
Error CS0518 Predefined type 'System.Void' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 46 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 46 Active
Error CS0518 Predefined type 'System.Void' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 47 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 47 Active
Error CS0246 The type or namespace name 'RecyclerView' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 51 Active
Error CS0518 Predefined type 'System.Void' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 56 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 56 Active
Error CS0246 The type or namespace name 'View' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 56 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 56 Active
Error CS0246 The type or namespace name 'Action<>' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 56 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 56 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 57 Active
Error CS0246 The type or namespace name 'Action<>' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 57 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 57 Active
Error CS0246 The type or namespace name 'EventArgs' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 65 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 67 Active
Error CS0246 The type or namespace name 'View' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 67 Active
Error CS0518 Predefined type 'System.Void' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 67 Active
Error CS0518 Predefined type 'System.Int32' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 68 Active
Error CS0518 Predefined type 'System.Void' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 68 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 25 Active
Error CS0246 The type or namespace name 'View' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 25 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 30 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 30 Active
Error CS1503 Argument 3: cannot convert from 'method group' to 'Action<StorelistAdapterClickEventArgs>' ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 30 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 40 Active
Error CS0518 Predefined type 'System.Array' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 44 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 44 Active
Error CS1061 'string[]' does not contain a definition for 'Length' and no accessible extension method 'Length' accepting a first argument of type 'string[]' could be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 44 Active
Error CS1729 'RecyclerView.ViewHolder' does not contain a constructor that takes 1 arguments ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 57 Active
首先,请确保您已经安装了这些 nuget 包。
请检查以下地方。
- 打开你的Adapter.cs,请注意
RecyclerView.Adapter
的命名空间,正确的命名空间是AndroidX.RecyclerView.Widget
- layout.xml 中
RecyclerView
的命名空间,在 Android X 中,应该像下面的代码那样更改 androidx.recyclerview.widget.RecyclerView
。
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/recyclerView1"/>
- 请打开你的Activiy.cs,你打包的
LinearLayoutManager
和RecyclerView
的命名空间是AndroidX.RecyclerView.Widget
这是我申请的 GIF 运行 Android Q.
这是我的演示。
嗨,我是 Xamarin Android 开发的新手,我已经成功地将我的应用程序迁移到 AndroidX,没有任何错误,但是当我添加 RecyclerView 适配器时,它给了我一堆错误。任何帮助深表感谢。谢谢
重现步骤:
- 在 Nuget 中添加了 Xamarin AndroidX 包
- 添加 RecyclerView 适配器
这是我的包裹:
<PackageReference Include="Xamarin.Android.Support.Design" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Android.Support.Core.Utils" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Android.Support.CustomTabs" Version="28.0.0.3" />
<PackageReference Include="Xamarin.AndroidX.Annotation">
<Version>1.1.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.AppCompat">
<Version>1.1.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.Browser">
<Version>1.2.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.CardView">
<Version>1.0.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData">
<Version>2.2.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.Media">
<Version>1.1.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.MediaRouter">
<Version>1.1.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.Migration">
<Version>1.0.2</Version>
</PackageReference>
<PackageReference Include="Xamarin.Essentials" Version="1.3.1" />
<PackageReference Include="Xamarin.Firebase.Auth">
<Version>60.1142.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.Firebase.Common">
<Version>60.1142.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.Firebase.Database">
<Version>60.1142.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.Google.Android.Material">
<Version>1.0.0</Version>
</PackageReference>
这是我的错误:
Severity Code Description Project File Line Suppression State
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 30 Active
Error CS1503 Argument 2: cannot convert from 'method group' to 'Action<StorelistAdapterClickEventArgs>' ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 30 Active
Error CS0246 The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 1 Active
Error CS0246 The type or namespace name 'Android' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 3 Active
Error CS0246 The type or namespace name 'Android' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 4 Active
Error CS0246 The type or namespace name 'Android' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 5 Active
Error CS0246 The type or namespace name 'RecyclerView' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 9 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 11 Active
Error CS0246 The type or namespace name 'EventHandler<>' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 11 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 11 Active
Error CS0518 Predefined type 'System.Void' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 11 Active
Error CS0518 Predefined type 'System.Void' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 11 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 12 Active
Error CS0246 The type or namespace name 'EventHandler<>' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 12 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 12 Active
Error CS0518 Predefined type 'System.Void' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 12 Active
Error CS0518 Predefined type 'System.Void' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 12 Active
Error CS0518 Predefined type 'System.String' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 13 Active
Error CS0518 Predefined type 'System.Void' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 15 Active
Error CS0518 Predefined type 'System.String' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 15 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 21 Active
Error CS0246 The type or namespace name 'RecyclerView' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 21 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 21 Active
Error CS0246 The type or namespace name 'ViewGroup' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 21 Active
Error CS0518 Predefined type 'System.Int32' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 21 Active
Error CS0518 Predefined type 'System.Void' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 35 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 35 Active
Error CS0246 The type or namespace name 'RecyclerView' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 35 Active
Error CS0518 Predefined type 'System.Int32' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 35 Active
Error CS0518 Predefined type 'System.Int32' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 44 Active
Error CS0115 'StorelistAdapter.ItemCount': no suitable method found to override ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 44 Active
Error CS0518 Predefined type 'System.Void' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 46 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 46 Active
Error CS0518 Predefined type 'System.Void' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 47 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 47 Active
Error CS0246 The type or namespace name 'RecyclerView' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 51 Active
Error CS0518 Predefined type 'System.Void' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 56 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 56 Active
Error CS0246 The type or namespace name 'View' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 56 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 56 Active
Error CS0246 The type or namespace name 'Action<>' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 56 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 56 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 57 Active
Error CS0246 The type or namespace name 'Action<>' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 57 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 57 Active
Error CS0246 The type or namespace name 'EventArgs' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 65 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 67 Active
Error CS0246 The type or namespace name 'View' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 67 Active
Error CS0518 Predefined type 'System.Void' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 67 Active
Error CS0518 Predefined type 'System.Int32' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 68 Active
Error CS0518 Predefined type 'System.Void' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 68 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 25 Active
Error CS0246 The type or namespace name 'View' could not be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 25 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 30 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 30 Active
Error CS1503 Argument 3: cannot convert from 'method group' to 'Action<StorelistAdapterClickEventArgs>' ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 30 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 40 Active
Error CS0518 Predefined type 'System.Array' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 44 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 44 Active
Error CS1061 'string[]' does not contain a definition for 'Length' and no accessible extension method 'Length' accepting a first argument of type 'string[]' could be found (are you missing a using directive or an assembly reference?) ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 44 Active
Error CS1729 'RecyclerView.ViewHolder' does not contain a constructor that takes 1 arguments ApplicationName C:\Users\SuperUser\source\repos\ApplicationName\ApplicationName\Adapter\StorelistAdapter.cs 57 Active
首先,请确保您已经安装了这些 nuget 包。
请检查以下地方。
- 打开你的Adapter.cs,请注意
RecyclerView.Adapter
的命名空间,正确的命名空间是AndroidX.RecyclerView.Widget
- layout.xml 中
RecyclerView
的命名空间,在 Android X 中,应该像下面的代码那样更改androidx.recyclerview.widget.RecyclerView
。
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/recyclerView1"/>
- 请打开你的Activiy.cs,你打包的
LinearLayoutManager
和RecyclerView
的命名空间是AndroidX.RecyclerView.Widget
这是我申请的 GIF 运行 Android Q.
这是我的演示。