首页 > 代码库 > 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第十三期 - RecycleView所有用法
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。