PullToRefresh-PinnedSection-ListView
====================================
A merge of PullToRefreshListView and PinnedSectionListView for Android.
## Library
Android-PullToRefresh: https://github.com/chrisbanes/Android-PullToRefresh
pinned-section-listview: https://github.com/beworker/pinned-section-listview
## Environment
Eclipse Luna, Android 4.2.2
## Screenshot
<img src="https://github.com/tongcpp/PullToRefresh-PinnedSection-ListView/blob/master/screen0.png" height="640" width="360" />
<img src="https://github.com/tongcpp/PullToRefresh-PinnedSection-ListView/blob/master/screen1.png" height="640" width="360" />
<img src="https://github.com/tongcpp/PullToRefresh-PinnedSection-ListView/blob/master/screen2.png" height="640" width="360" />
## 为什么做PullToRefresh-PinnedSection-ListView
前段时间因为项目需求,需要在Android中对ListView同时增加下拉刷新和分段头悬停的效果,受到[dkmeteor](https://github.com/dkmeteor)的启发,Merge了两个Github上的开源项目:
* [Android-PullToRefresh](https://github.com/chrisbanes/Android-PullToRefresh)(handmark版,目前已不再更新)
* [StickyListHeaders](https://github.com/emilsjolander/StickyListHeaders)(目前版本为2.x)
由于既有项目里的StickyListHeaders代码为1.x版本,StickyListHeadersListView继承自ListView,故与handmark版的PullToRefreshListView做merge时很顺畅;
但2.x版的StickyListHeadersListView继承自FrameLayout,与PullToRefresh的融合并不顺利,若要整理拆分出一个独立的lib时遇到很多的问题,
故在分断头悬停需求上采用了另一个类似的开源项目:
* [pinned-section-listview](https://github.com/beworker/pinned-section-listview)
## 我是如何做的
前面已经介绍过这个过程是“很顺畅”的:
1.Library方面,基于PullToRefresh的Library修改,首先使其依赖StickyListHeaders的Library,通过拷贝src/com/handmark/pulltorefresh/library/PullToRefreshListView.java类,
新建PullToRefreshPinnedSectionListView.java类;
2.修改PullToRefreshPinnedSectionListView类中createListView()方法,注释以下代码
// if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) {
// lv = new InternalListViewSDK9(context, attrs);
// } else {
// lv = new InternalListView(context, attrs);
// }
添加
lv = new PinnedSectionListView(context, attrs);
3.Example方面,基于pinned-section-listview的example修改,令其依赖PullToRefresh的Library;
4.修改主类资源文件activity_main.xml,设置List组件为新类:
<com.handmark.pulltorefresh.library.PullToRefreshPinnedSectionListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:headerDividersEnabled="false"
android:footerDividersEnabled="false"
android:divider="@null"
/>
5.改写SampleActivity.java类中getListView()方法:
mpPullToRefreshPinnedSectionListView = (PullToRefreshPinnedSectionListView) findViewById(R.id.list);
return mpPullToRefreshPinnedSectionListView.getRefreshableView();
即可通过
ListView list = getListView();
继续进行原example其他操作,详情可阅读[项目代码](https://github.com/tongcpp/PullToRefresh-PinnedSection-ListView/blob/master/example/src/com/hb/examples/SampleActivity.java)
## 另一种实现方式
本例的实现方式依赖于handmark版下拉刷新组件的灵活性,更重要的一点,要求分段头悬停组件是继承自ListView实现;
故同理也可用handmark版下拉刷新组件和1.x版的StickyListHeaders组件实现;
另一种实现方式为[pull-to-refresh-sticky-list](https://github.com/dkmeteor/pull-to-refresh-sticky-list),
其采取合并的是2.x版的StickyListHeaders和johannilsson的android-pulltorefresh,实现形式不同,但效果类似,看过代码后实现起来也“相当顺畅”,有兴趣的同学可以参照此项目;
## 建议
建议在熟悉或使用过原有组件类库的前提下使用本类库。
没有合适的资源?快使用搜索试试~ 我知道了~
Android中listView分组显示内容和下拉刷新
共104个文件
xml:41个
java:24个
png:17个
4星 · 超过85%的资源 需积分: 10 132 下载量 186 浏览量
2015-07-17
10:35:39
上传
评论
收藏 829KB ZIP 举报
温馨提示
listview的分组显示数据,在项目中非常常用,尤其是在理财项目中,这个demo是我在网上找的
资源推荐
资源详情
资源评论
收起资源包目录
Android中listView分组显示内容和下拉刷新 (104个子文件)
.classpath 466B
.classpath 466B
.classpath 466B
.gitignore 271B
.gitignore 14B
.gitignore 14B
.gitignore 14B
android-support-v4.jar 384KB
PullToRefreshBase.java 45KB
PinnedSectionListView.java 18KB
PullToRefreshAdapterViewBase.java 14KB
LoadingLayout.java 12KB
SampleActivity.java 12KB
PullToRefreshPinnedSectionListView.java 10KB
PullToRefreshListView.java 10KB
IPullToRefresh.java 8KB
OverscrollHelper.java 8KB
PullToRefreshWebView.java 5KB
IndicatorLayout.java 5KB
FlipLoadingLayout.java 5KB
PullToRefreshWebView2.java 4KB
PullToRefreshHorizontalScrollView.java 3KB
RotateLoadingLayout.java 3KB
PullToRefreshExpandableListView.java 3KB
PullToRefreshScrollView.java 3KB
PullToRefreshGridView.java 3KB
SoundPullEventListener.java 3KB
ViewCompat.java 2KB
LoadingLayoutProxy.java 2KB
ILoadingLayout.java 2KB
EmptyViewMethodAccessor.java 1KB
Utils.java 345B
LICENSE 11KB
LICENSE 1KB
README.md 4KB
screen1.png 71KB
screen0.png 70KB
screen2.png 68KB
default_ptr_rotate.png 49KB
default_ptr_rotate.png 49KB
default_ptr_rotate.png 48KB
ic_launcher-web.png 44KB
ic_launcher.png 11KB
ic_launcher.png 7KB
ic_launcher.png 6KB
ic_launcher.png 3KB
default_ptr_flip.png 2KB
default_ptr_flip.png 2KB
default_ptr_flip.png 2KB
indicator_arrow.png 445B
indicator_arrow.png 429B
indicator_arrow.png 390B
org.eclipse.jdt.core.prefs 173B
org.eclipse.jdt.core.prefs 173B
org.eclipse.jdt.core.prefs 173B
.project 839B
.project 827B
.project 823B
project.properties 671B
project.properties 584B
project.properties 438B
proguard-project.txt 781B
proguard-project.txt 781B
attrs.xml 4KB
pull_to_refresh_header_vertical.xml 2KB
pull_to_refresh_header_horizontal.xml 1KB
pom.xml 1KB
AndroidManifest.xml 869B
slide_out_to_top.xml 866B
slide_in_from_top.xml 866B
slide_in_from_bottom.xml 865B
slide_out_to_bottom.xml 865B
main.xml 805B
pull_refresh_strings.xml 750B
pull_refresh_strings.xml 729B
styles.xml 679B
indicator_bg_bottom.xml 595B
indicator_bg_top.xml 595B
styles.xml 380B
strings.xml 376B
colors.xml 361B
AndroidManifest.xml 360B
dimens.xml 360B
activity_main.xml 357B
pull_refresh_strings.xml 356B
pull_refresh_strings.xml 325B
styles.xml 323B
pull_refresh_strings.xml 313B
pull_refresh_strings.xml 310B
pull_refresh_strings.xml 310B
pull_refresh_strings.xml 308B
pull_refresh_strings.xml 306B
pull_refresh_strings.xml 306B
pull_refresh_strings.xml 306B
pull_refresh_strings.xml 305B
pull_refresh_strings.xml 302B
pull_refresh_strings.xml 302B
pull_refresh_strings.xml 301B
pull_refresh_strings.xml 300B
pull_refresh_strings.xml 300B
共 104 条
- 1
- 2
资源评论
- VaeZyc2016-03-18可以借鉴!
- Lychao丶2016-08-23还可以 有点用
- bluecat3332018-02-27可以用,一切正常
zhaihaohao1
- 粉丝: 314
- 资源: 321
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功