xamarin.android binding thorw 'does not implement inherited abstract member 'RecyclerView.Adapter.OnCreateViewHolder(ViewGroup, int)'

本小妞迷上赌 提交于 2019-12-12 04:47:53

问题


I am binding the github project ChatKit

I do this xml

<attr name="managedType" path="/api/package[@name='com.stfalcon.chatkit.messages']/class[@name='MessagesListAdapter']/method[@name='onBindViewHolder']/parameter[1]">Android.Support.V7.Widget.RecyclerView.ViewHolder</attr>
  <attr name="managedType" path="/api/package[@name='com.stfalcon.chatkit.messages']/class[@name='MessagesListAdapter']/method[@name='onBindViewHolder']/parameter[2]">int</attr>

but vs still throw the error for me:

1>D:\TempApps\ChatKitDebugBinding\ChatKitDebugBinding\obj\Debug\generated\src\Com.Stfalcon.Chatkit.Messages.MessagesListAdapter.cs(10,23,10,42): error CS0534: 'MessagesListAdapter' does not implement inherited abstract member 'RecyclerView.Adapter.OnCreateViewHolder(ViewGroup, int)'

And there is any way to fix it?


回答1:


The easiest way to fix this is by partial classes. You can do this by creating a partial class of MessagesListAdapter with your appropriate namespace:

namespace Com.Your.Namespace
{
    partial class MessagesListAdapter
    {
    }
}

Next you can implement the overrides inside this partial class:

public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
{
    throw new NotImplementedException();
}

public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
{
    throw new NotImplementedException();
}

Finally you can look through the source code and use the newly generated binding classes to implement these methods in C#:

OnBindViewHolder

OnCreateViewHolder



来源:https://stackoverflow.com/questions/45754424/xamarin-android-binding-thorw-does-not-implement-inherited-abstract-member-rec

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!