Android Studio第十三期 - RecycleView所有用法
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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第十三期 - RecycleView所有用法的主要内容,如果未能解决你的问题,请参考以下文章
Android Studio 第七十三期 - Android Glide4.7.3用法大全支持九宫格
Android Studio 第五十三期 - 自定义EditText密码键盘
Android Studio第二十三期 - TextView自适应缩放大小 国外大神的library