PinnedSectionListView使用技巧
来源:互联网 发布:下载默默聊天软件 编辑:程序博客网 时间:2024/06/04 00:40
githab上一款很好用的分组的listview滑动中固定标题的实现
https://github.com/beworker/pinned-section-listview
查看demo,知道使用pinned-section-listview,仅仅需要将封装好的PinnedSectionListView拷贝至自己的项目中
<com.hb.views.PinnedSectionListView android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="wrap_content" />
除此之外还需要添加一部分代码在adapter中:
// Our adapter class implements 'PinnedSectionListAdapter' interface class MyPinnedSectionListAdapter extends BaseAdapter implements PinnedSectionListAdapter { ... // We implement this method to return 'true' for all view types we want to pin @Override public boolean isItemViewTypePinned(int viewType) { return viewType == <type to be pinned>; } }
isItemViewTypePinned 这个方法的作用是确定哪个item是title,当item为需要固定的title时,返回true。
那么如何确定item是否是title?需要重写另外两个构造方法:
所给的demo中是这样确定的:
再写一种demo:@Override public int getViewTypeCount() { return 2; } @Override public int getItemViewType(int position) { return getItem(position).type; } @Override public boolean isItemViewTypePinned(int viewType) { return viewType == Item.SECTION; }getViewTypeCount()有几种类型的item<pre name="code" class="java" style="color: rgb(148, 82, 119); font-size: 14px; font-weight: bold; line-height: 20px;">getItemViewType(int position)返回item的类型,与<span style="font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;">isItemViewTypePinned(int viewType)对应</span>
@Override public int getViewTypeCount() { return 2; }
@Overridepublic int getItemViewType(int position) {// TODO Auto-generated method stubItem item=items.get(position);if(item.isSection()){return 1;}else{return 0;}}@Overridepublic boolean isItemViewTypePinned(int viewType) {// TODO Auto-generated method stubif(viewType==1){return true;}elsereturn false;}
0 0
- PinnedSectionListView使用技巧
- PinnedSectionListView使用
- PinnedSectionListView使用详解
- Android----PinnedSectionListView
- [带gif效果图] listview悬浮标题顶上去效果,PinnedSectionListview使用解析,快速明确达到效果
- 使用开源控件PinnedSectionListView(头部驻留)的时候低版本api出现ClassCastException异常
- Android PinnedSectionListView 收缩
- PinnedSectionListView的实现原理
- Android PinnedSectionListView 收缩
- Android PinnedSectionListView 收缩
- PinnedSectionListView源码分析
- PinnedSectionListView原理完全透析
- PinnedSectionListView用法详解
- PinnedSectionListView实现手机通讯录功能
- 【技巧】UE使用技巧
- Android基于PinnedSectionListView实现联系人通讯录
- 通讯录分组 开源框架 PinnedSectionListView
- Android PinnedSectionListView异常崩溃报错
- 如何保证数据的安全性
- 【iOS开发-58】tableView初识:5个重要方法的使用和2种样式的区别
- MFC碰到的access violation错误
- Eclipse 保存文件时自动格式化代码
- DES加密算法详解
- PinnedSectionListView使用技巧
- eclipse环境下Web Service Explorer工具使用
- maven parent pom
- Spring WebApplicationInitializer and ApplicationContextInitializer confusion
- 计算本月有几天(2)
- C++类大小的一些说明
- 深入PHP内核(一)——弱类型变量原理探究
- 【PHP】PHP入门第一章
- rtmutex赏析