Skip to content

Files

Failed to load latest commit information.

Latest commit

 Cannot retrieve latest commit at this time.

History

History
 
 

pinned-section-listview-demo

README.md

Android 开源项目之 pinned-section-listview

这是一个简单的listview控件,可以简单的使SectionItem悬停在title,直到下一个SectionItem出现。类似效果淘宝购物车功能等。

功能

  • 快速的滚动
  • 点击SectionItem
  • 下拉刷新

这是一些简单的功能,你可以fork项目添加你自己的想法:) 这是个简单的Library,根本不会影响你功能的大小,他甚至只是一个类。

使用方法

使用方法非常简单

1.在你的layout.xml中使用PinnedSectionListView来代替系统提供的ListView

<com.caesar.PSL_demo.library.PinnedSectionListView
            android:id="@+id/listview"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@android:color/transparent"
            android:cacheColorHint="@android:color/transparent"
            android:divider="@android:color/transparent"
            android:footerDividersEnabled="false"
            android:headerDividersEnabled="false" />

看起来很简单

2.书写一个MyAdatper这个类继承于BaseAdaper,当然也可以继承其他Adaper,然后实现PinnedSectionListAdapter这个接口 添加一个简单的方法 isItemViewTypePinned(int viewType) 这个方法如果返回true 那么这个Item就是你要SctionItem.

//实现了PinnedSctionListAdapter 这个接口
public class PinnedAdapter extends BaseAdapter implements PinnedSectionListAdapter{
	
···

// 实现这个方法,返回true那么这个item就是SctionItem

     @Override
     public boolean isItemViewTypePinned(int viewType) {
         return viewType == <type to be pinned>;
     }


}

以上就是PinnedSectionListview的使用方法,例子可以在example文件夹中找到.

代码分析

1.这是一个基于ListView 控件的一个扩展

 public class PinnedSectionListView extends ListView {
 
    ···
 } 

感谢

感谢 Sergej Shafarenka期待有更好的开源项目,造福开发者。