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

Custom adapter has a generic bug #205

Open
chenyannan opened this issue Oct 10, 2020 · 2 comments
Open

Custom adapter has a generic bug #205

chenyannan opened this issue Oct 10, 2020 · 2 comments

Comments

@chenyannan
Copy link

Is this a general databinding issue or question? You are more likely to get a
response from somewhere like
StackOverflow.

Issue

Please be as detailed as possible and include a (formatted) stacktrace if
relevant. A sample project that reproduce the problem goes a long way!

Feature Request

Please give an example use-case on why the feature is useful. Keep in mind the
scope of this project is to bind data to RecyclerView/ListView/ViewPager etc,
not to add additional features to those views.

@chenyannan
Copy link
Author

implementation 'me.tatarka.bindingcollectionadapter2:bindingcollectionadapter:4.0.0'
implementation 'me.tatarka.bindingcollectionadapter2:bindingcollectionadapter-recyclerview:4.0.0'
implementation 'me.tatarka.bindingcollectionadapter2:bindingcollectionadapter-viewpager2:4.0.0'

`public class MainPageViewModel extends RVPresenterViewModel<NewsInfoBean, NewsItemObservable> {

public final ObservableList<NewsItemObservable> items = new ObservableArrayList<>();
public final ItemBinding<NewsItemObservable> itemBinding = ItemBinding.of(new OnItemBind<NewsItemObservable>() {
    @Override
    public void onItemBind(@NonNull ItemBinding itemBinding, int position, NewsItemObservable item) {
        itemBinding.set(BR.item, R.layout.item_news);

    }
});`

`

    <variable
        name="mainPageVM"
        type="com.demo.mvvmapplication.ui.fragment.home.MainPageViewModel" />

    <variable
        name="adapter"
        type="me.tatarka.bindingcollectionadapter2.BindingRecyclerViewAdapter"/>
</data>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/fmpRecyclerView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="40dp"
        android:focusable="false"
        android:overScrollMode="never"
        app:adapter="@{adapter}"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
        app:itemBinding="@{mainPageVM.getBindingItem()}"
        app:items="@{mainPageVM.getBindingItems()}"/>`

\databinding\FragmentMainPageBindingImpl.java:125: 错误: 无法将类 BindingRecyclerViewAdapters中的方法 setAdapter应用到给定类型; me.tatarka.bindingcollectionadapter2.BindingRecyclerViewAdapters.setAdapter(this.fmpRecyclerView, mainPageVMGetBindingItem, mainPageVMGetBindingItems, (me.tatarka.bindingcollectionadapter2.BindingRecyclerViewAdapter)null, (me.tatarka.bindingcollectionadapter2.BindingRecyclerViewAdapter.ItemIds)null, (me.tatarka.bindingcollectionadapter2.BindingRecyclerViewAdapter.ViewHolderFactory)null, (androidx.recyclerview.widget.AsyncDifferConfig)null); ^ 需要: RecyclerView,ItemBinding<? super T>,List<T>,BindingRecyclerViewAdapter<T>,ItemIds<? super T>,ViewHolderFactory,AsyncDifferConfig<T> 找到: RecyclerView,ItemBinding<CAP#1>,ObservableList<CAP#2>,BindingRecyclerViewAdapter,ItemIds,ViewHolderFactory,AsyncDifferConfig 原因: 无法推断类型变量 T (参数不匹配; ItemBinding<CAP#1>无法转换为ItemBinding<? super T>) 其中, T是类型变量: T扩展已在方法 <T>setAdapter(RecyclerView,ItemBinding<? super T>,List<T>,BindingRecyclerViewAdapter<T>,ItemIds<? super T>,ViewHolderFactory,AsyncDifferConfig<T>)中声明的Object 其中, CAP#1,CAP#2是新类型变量: CAP#1从?的捕获扩展Object CAP#2从?的捕获扩展Object

@chenyannan
Copy link
Author

adapter should can add header and fooder

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

No branches or pull requests

1 participant