Project Source
The project described herein is open source, source address
Why do Pulltorefresh-pinnedsection-listview
The previous time because of the project needs, the need to add a drop-down refresh and segmented head hover effect on the ListView in Android, inspired by Dkmeteor, merges two open source projects on GitHub:
Android-pulltorefresh (Handmark version, currently no longer updated)
stickylistheaders (current version is 2.x)
As the existing project Stickylistheaders code for the 1.x version, Stickylistheaderslistview inherit from the ListView, so with the Handmark version of Pulltorefreshlistview do the merge is smooth;
However, the 2.x version of Stickylistheaderslistview inherited from the Framelayout, and Pulltorefresh fusion is not smooth, to sort out a separate Lib encountered a lot of problems, so in the split-off hover demand on the use of another similar open source project:
Pinned-section-listview
How I did it.
The process described earlier is "very smooth":
1.Library, based on the Pulltorefresh Library modification, first make it dependent on the Stickylistheaders library, by copying src/com/handmark/pulltorefresh/ Library/pulltorefreshlistview.java class, New Pulltorefreshpinnedsectionlistview.java class;
2. Modify the Createlistview () method in the Pulltorefreshpinnedsectionlistview class, commenting the following code
if (VERSION. Sdk_int >= version_codes. Gingerbread) {// LV = new InternalListViewSDK9 (context, attrs);/ } else {// LV = new Internallistview ( context, attrs);// }
Add to
LV = new Pinnedsectionlistview (context, attrs);
3.Example, based on the Pinned-section-listview example modification, making it dependent on the Pulltorefresh library;
4. Modify the main class resource file Activity_main.xml, set the list component to the new class:
<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. Rewrite the Getlistview () method in the Sampleactivity.java class:
Mppulltorefreshpinnedsectionlistview = (Pulltorefreshpinnedsectionlistview) Findviewbyid (R.id.list); return Mppulltorefreshpinnedsectionlistview.getrefreshableview ();
You can pass
ListView list = Getlistview ();
Continue with the original example other operations, details can read the project code
Another way to implement
The implementation of this example relies on the flexibility of the Handmark version of the drop-down refresh component, more importantly, requires that the segmented head hover component is inherited from the ListView implementation, so the same can be used Handmark version of the drop-down refresh components and 1.x version of the Stickylistheaders component implementation;
Another way to achieve this is pull-to-refresh-sticky-list, Its merger is the 2.x version of the stickylistheaders and Johannilsson Android-pulltorefresh, the implementation of different forms, but similar effects, read the code after the implementation is also "quite smooth", interested students can refer to this project;
Suggestions
It is recommended to use this class library if you are familiar with or have used the original Component class library.
Android Development-drop-down refresh and segmented header hover list