Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

item中绑定adapter报错binding:adapter="@{vm.mAdapter}" #187

Open
bujinhai opened this issue Apr 24, 2020 · 9 comments
Open

item中绑定adapter报错binding:adapter="@{vm.mAdapter}" #187

bujinhai opened this issue Apr 24, 2020 · 9 comments

Comments

@bujinhai
Copy link

错误: 无法将类 BindingRecyclerViewAdapters中的方法 setAdapter应用到给定类型;
需要: RecyclerView,ItemBinding<? super T>,List,BindingRecyclerViewAdapter,ItemIds<? super T>,ViewHolderFactory,AsyncDifferConfig
找到: RecyclerView,ItemBinding,ObservableList,ContactAdapter,ItemIds,ViewHolderFactory,AsyncDifferConfig
原因: 推论变量 T 具有不兼容的限制范围
等式约束条件: CompanyInfo,ContactItemViewModel
上限: ContactItemViewModel,Object
其中, T是类型变量:
T扩展已在方法 setAdapter(RecyclerView,ItemBinding<? super T>,List,BindingRecyclerViewAdapter,ItemIds<? super T>,ViewHolderFactory,AsyncDifferConfig)中声明的Object

@evant
Copy link
Owner

evant commented Apr 25, 2020

Thank you for reporting your issue. In order to look into it, can you please provide a sample project and clear steps to reproduce?

@nonelg
Copy link

nonelg commented May 1, 2020

Thank you for reporting your issue. In order to look into it, can you please provide a sample project and clear steps to reproduce?

android.build.gradle version 3.5.3
and setAdapter in Activity/Fragment(not in ViewModel), This is different from the sample code

@nonelg
Copy link

nonelg commented May 1, 2020

Thank you for reporting your issue. In order to look into it, can you please provide a sample project and clear steps to reproduce?

If I define the adapter in the ViewModel like the simple code, there is no problem, But I don't know if this code will cause a memory leak?

@skyofsky
Copy link

  1. build.gradle Modify upgrade in file:
    classpath 'com.android.tools.build:gradle:3.6.3'

  2. gradle-wrapper.properties Modify upgrade in file:
    distributionUrl=https://services.gradle.org/distributions/gradle-5.6.4-all.zip

The following questions will appear:
E:\Android\AndroidStudioProjects\MVVMHabit-master\app\build\generated\ap_generated_sources\debug\out\com\goldze\mvvmhabit\databinding\FragmentNetworkBindingImpl.java:158: 错误: 无法将类 BindingRecyclerViewAdapters中的方法 setAdapter应用到给定类型;
me.tatarka.bindingcollectionadapter2.BindingRecyclerViewAdapters.setAdapter(this.mboundView2, viewModelItemBinding, viewModelObservableList, adapter, (me.tatarka.bindingcollectionadapter2.BindingRecyclerViewAdapter.ItemIds)null, (me.tatarka.bindingcollectionadapter2.BindingRecyclerViewAdapter.ViewHolderFactory)null);
^
需要: RecyclerView,ItemBinding,List,BindingRecyclerViewAdapter,ItemIds<? super T>,ViewHolderFactory
找到: RecyclerView,ItemBinding,ObservableList,BindingRecyclerViewAdapter<CAP#1>,ItemIds,ViewHolderFactory
原因: 推断类型不符合等式约束条件
推断: CAP#1
等式约束条件: CAP#1,NetWorkItemViewModel
其中, T是类型变量:
T扩展已在方法 setAdapter(RecyclerView,ItemBinding,List,BindingRecyclerViewAdapter,ItemIds<? super T>,ViewHolderFactory)中声明的Object
其中, CAP#1是新类型变量:

@skyofsky
Copy link

Project address in question:https://github.com/goldze/MVVMHabit uses binding collection adapter

@zhengpengzheng
Copy link

study

@zhouzitao
Copy link

怎么解决呢

@android-taoge
Copy link

android-taoge commented May 19, 2021

我也遇到这个问题了,如何解决?(I am meet this problem too, how can i solve this problem?)

@lcj0304
Copy link

lcj0304 commented Mar 7, 2022

在xml导入的类名后面加入 <Object>试试.

<variable
            name="ViewModel"
            type="xxx.xxx.DataListViewModel&lt;Object>" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants