问题描述
如何使用recyclerview实现水平gridlayoutmanager.固定行数.和水平滚动.这样...
How to implement horizontal gridlayoutmanager with recyclerview.Fixed row count. and horizontal scroll.Like this...
gridLayoutManager = new GridLayoutManager(getContext(), 1, GridLayoutManager.HORIZONTAL, false);
recyclerView.setLayoutManager(gridLayoutManager);
recyclerView.setHasFixedSize(true);
我尝试这样做.但这并没有在项目中显示任何内容.
I try do this. but this is not show anything in item.
推荐答案
- 安装RecyclerAdapter,ViewHolder.
- 实例化RecyclerAdapter,设置其适配器.
-
指定ROWSCOUNT(您的图片上有3行):
GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), ROWSCOUNT, GridLayoutManager.HORIZONTAL, false);
- Implement RecyclerAdapter, ViewHolder.
- Instantiate RecyclerAdapter, set its' adapter.
Specify ROWSCOUNT (there are 3 rows on your picture):
GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), ROWSCOUNT, GridLayoutManager.HORIZONTAL, false);
设置布局管理器:recyclerView.setLayoutManager(gridLayoutManager);
Set layout manager: recyclerView.setLayoutManager(gridLayoutManager);
显示您的回收站视图setContentView(recyclerView);
Show your recycler view setContentView(recyclerView);
这篇关于如何实现水平网格布局管理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!