[英]Swipe left and right on RecyclerView
In Xamarin Android I have a screen with a RecyclerView. 在Xamarin Android中,我的屏幕带有RecyclerView。 The RecyclerView's data is filtered by a date. RecyclerView的数据按日期过滤。 What I want to achieve is that I can use a swipe left and swipe right on the RecyclerView to go to the next or previous date, but let a single tap/click on an item be handled by the RecyclerView itself. 我想要实现的是,我可以在RecyclerView上向左滑动和向右滑动以转到下一个或上一个日期,但是让RecyclerView本身处理一个项目即可。 Does someone know how to do this? 有人知道该怎么做吗?
What I want to achieve is that I can use a swipe left and swipe right on the RecyclerView to go to the next or previous date, but let a single tap/click on an item be handled by the RecyclerView itself 我想要实现的是,我可以在RecyclerView上向左滑动和向右滑动来转到下一个或上一个日期,但是让RecyclerView自己处理一个项目即可
Basically what you need to do is to embed your RecyclerView
into ViewPager
. 基本上,您需要做的是将RecyclerView
嵌入到ViewPager
。 You can do that by following below steps: 您可以按照以下步骤操作:
Install Xamarin.Android.support.v7.App
and Xamarin.Android.Support.v4
nuget packages and their dependencies. 安装Xamarin.Android.support.v7.App
和Xamarin.Android.Support.v4
nuget软件包及其依赖项。
Create a Fragment and its layout as page of your ViewPager
and also responsible for demonstrating the RecyclerView
. 在ViewPager
页面上创建一个Fragment及其布局,并负责演示RecyclerView
。
Create the ViewPager
and its adapter and use it in your Activity
. 创建ViewPager
及其适配器,并在Activity
使用它。
Generate RecyclerView
in Fragment's OnCreateView
. 在Fragment的OnCreateView
生成RecyclerView
。
Notes: you also need to conduct your data source to get the group information of your data, in order to pass it to ViewPager
. 注意:您还需要执行数据源以获取数据的组信息,然后将其传递给ViewPager
。
For detailed codes, you can refer to my complete demo: EmbedRecyclerViewToViewPager ; 有关详细代码,请参阅我的完整演示: EmbedRecyclerViewToViewPager ;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.