Adding Multiple Presenters to ArrayObjectAdapter of Android Leanback

馋奶兔 提交于 2020-01-06 05:34:26

问题


I want to display two different types of cards in the same row (ListRow).

I tried to modify the Presenter class by adding viewType similar to dealing with displaying multiple row types in RecyclerVew but it did not work.

I tried digging into the Presenter and ArrayObjectAdapter code but there is no obvious option to achieve this. If someone has done this then please point me in the right direction.


回答1:


You can use ClassPresenterSelector to show different types of cards in the same row

Example

ClassPresenterSelector selector = new ClassPresenterSelector();

YourDetailTypePresenter detailPresenter = new YourDetailTypePresenter();
YourImageTypePresenter imagePresenter = new YourImageTypePresenter();

selector.addClassPresenter(DetailsOverviewRow.class, detailPresenter);
selector.addClassPresenter(ImageOverviewRow.class, imagePresenter);

mRowsAdapter = new ArrayObjectAdapter(selector);


来源:https://stackoverflow.com/questions/47953258/adding-multiple-presenters-to-arrayobjectadapter-of-android-leanback

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