【Android Studio第十三期 - RecycleView所有用法】时人不识凌云木,直待凌云始道高。这篇文章主要讲述Android Studio第十三期 - RecycleView所有用法相关的知识,希望能为你提供帮助。
综合了一下hongyang和loader的RecycleView的所有场景用法:
1.ListView列表分页用法核心代码:
private void createAdapter(){ mAdapter = new RecycleAdapter1(this); LinearLayoutManager mLinearLayoutManager1 = new LinearLayoutManager(this); mLinearLayoutManager1.setOrientation(OrientationHelper.VERTICAL); recyclerView.setLayoutManager(mLinearLayoutManager1); recyclerView.setAdapter(mAdapter); }
效果如下图:
文章图片
2.GridView列表分页用法核心代码:
private void createAdapter(){ mAdapter = new RecycleAdapter2(this); recyclerView.setLayoutManager(new GridLayoutManager(this, 2)); recyclerView.setAdapter(mAdapter); }
效果如下图:
文章图片
3.ListView列表AddHeadAndAddFooter用法核心代码:
private void createAdapter() { ll_header = (LinearLayout) View.inflate(this, R.layout.activity_addheader, null); ll_footer = (LinearLayout) View.inflate(this, R.layout.activity_addfooter, null); mAdapter = new RecycleAdapter3(this); LinearLayoutManager mLinearLayoutManager1 = new LinearLayoutManager(this); mLinearLayoutManager1.setOrientation(OrientationHelper.VERTICAL); recyclerView.setLayoutManager(mLinearLayoutManager1); // recyclerView.setAdapter(mAdapter); } private void addAdapter() { mHeaderAndFooterWrapper = new HeaderAndFooterWrapper(mAdapter); mHeaderAndFooterWrapper.addHeaderView(ll_header); mHeaderAndFooterWrapper.addFootView(ll_footer); recyclerView.setAdapter(mHeaderAndFooterWrapper); }
效果如下图:
文章图片
4.GridView列表AddHeadAndAddFooter用法核心代码:
private void createAdapter() { ll_header = (LinearLayout) View.inflate(this, R.layout.activity_addheader, null); ll_footer = (LinearLayout) View.inflate(this, R.layout.activity_addfooter, null); mAdapter = new RecycleAdapter4(this); recyclerView.setLayoutManager(new GridLayoutManager(this, 2)); // recyclerView.setAdapter(mAdapter); } private void addAdapter() { mHeaderAndFooterWrapper = new HeaderAndFooterWrapper(mAdapter); mHeaderAndFooterWrapper.addHeaderView(ll_header); mHeaderAndFooterWrapper.addFootView(ll_footer); recyclerView.setAdapter(mHeaderAndFooterWrapper); }
效果如下图:
文章图片
附:提供了几个常用控件的使用:
1.SwipeReFreshLayout的用法:
onRefresh();
2.ShapeLoading的用法:
ShowLoadingUtil.showProgressDialog2(MainActivity4.this, "正在加载...");
这回够诚意吧~么么哒~下班肥家~吃饭饭~
地址:https://github.com/geeklx/MyApplication/tree/master/p010_recycleviewall
本文出自 “梁肖技术中心” 博客,请务必保留此出处http://liangxiao.blog.51cto.com/3626612/1855928
推荐阅读
- Android studio启动后卡在refreshing gradle project
- android 近百个源码项目
- Android项目源码分享
- Android开发案例 - 淘宝商品详情
- android开发从零开始 -----Android通用流行框架大全
- Android Handler消息传递机制
- android ontouch事件分发机制
- Android开发华为手机无法看log日志解决方法
- 把Android原生的View渲染到OpenGL Texture