简体   繁体   English

在viewpager的一页中集成了多个recyclerview

[英]more than one recyclerview integrated in one page of a viewpager

I am somewhat new to android development and I am working on my final year project. 我是android开发的新手,正在从事我的最后一年的项目。

I have this problem, and I don't have a clue how this from the images image 1 image 2 image 3 was achieved. 我有这个问题,我不知道如何从图像图像1 图像2 图像3实现这一点。 The way I see it, it looks like a viewpager but it has 3 recycler views probably in a linear layout in each view. 以我的方式看,它看起来像一个viewpager,但它在每个视图中可能有3个以线性布局排列的回收视图。

Now my problem is that I have only done a viewpager which will use values from one Jsonarray item for each view in the vp. 现在我的问题是我只做过一个viewpager,它将对vp中的每个视图使用一个Jsonarray项中的值。 I might be looking at it the wrong way so I would appreciate any other theories to achieve the above. 我可能会以错误的方式看待它,因此,我将感激任何其他实现上述目标的理论。

The only difference between these 3 tabs is the data. 这三个标签之间的唯一区别是数据。 You have the same item everywhere. 您到处都有相同的项目。 I would suggest to implement 1 Fragment which will hold 1 RecyclerView and all the logic to set items to Adapter, handle click events etc. 我建议实现1个片段,其中将包含1个RecyclerView以及将项目设置为Adapter,处理click事件等的所有逻辑。

But you need to pass the actual array of elements to this Fragment from outside, no logic for getting data from some source should be written in Fragment. 但是您需要将元素的实际数组从外部传递到此Fragment,因此不应在Fragment中编写用于从某个源获取数据的逻辑。

And in your activity, you should have get the actual data, for example 3 Arraylists of Items, then you need to have a ViewPager, and add 3 instances of the Fragment to this ViewPager with different list of items. 并且在您的活动中,您应该获取了实际数据,例如3个项的Arraylists,然后需要有一个ViewPager,并将3个Fragment的实例添加到具有不同项列表的ViewPager中。

In general that's it. 总的来说就是这样。 If you need more details, well first provide more details and just let me know. 如果您需要更多详细信息,请先提供更多详细信息,然后告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM