We know that the QQ friends list category is implemented using expandablelistview, but it is improved on this basis. For example, when you open a group, the group title will be suspended at the top of the list.
It is convenient for users to close the group. The effect is similar:
The implementation code is as follows:
@ Overridepublic void onscroll (abslistview view, int firstvisibleitem, int visibleitemcount, int totalitemcount) {// prevents the first entry of a Samsung or meizu mobile phone from being pulled down, if (firstvisibleitem = 0) {view_flotage.setvisibility (view. gone);} // display and hide the textview when sliding. Int NPOs = view. pointtoposition (0, 0); If (NPOs! = Adapterview. invalid_position) {long Pos = expandablelist. getexpandablelistposition (NPOs); int childpos = expandablelistview. getpackedpositionchild (POS); Final int grouppos = expandablelistview. getpackedpositiongroup (POS); If (childpos = adapterview. invalid_position) {view groupview = expandablelist. getchildat (NPOs-expandablelist. getfirstvisibleposition (); indicatorgroupheight = groupview. getheight ();} If (indicatorgroupheight = 0) {return;} // If (isexpanded) {If (count_expand> 0) {the_group_expand_position = grouppos; group_content.settext (groupdata. get (the_group_expand_position ). get ("group_text"); If (the_group_expand_position! = Grouppos |! Expandablelist. isgroupexpanded (grouppos) {view_flotage.setvisibility (view. gone);} else {view_flotage.setvisibility (view. visible) ;}} if (count_expand = 0) {view_flotage.setvisibility (view. gone) ;}} if (the_group_expand_position =-1) {return;}/*** calculate point (0, indicatorgroupheight) */INT showheight = getheight (); marginlayoutparams layoutparams = (marginlayoutparams) view_flotage.getlayoutparams (); // you can obtain the number of layoutparams for floating entries to slide out of the screen. topmargin =-(indicatorgroupheight-showheight); view_flotage.setlayoutparams (layoutparams );}
Some mobile phone brands may be different in the following situations:
Therefore, you need to add the following code:
// Prevent the first entry of Samsung, meizu, and other mobile phones from being pulled down. If (firstvisibleitem = 0) {view_flotage.setvisibility (view. Gone );}
--------------------------------------------------------------------------------
Recently some netizens need code, now attached. http://download.csdn.net/detail/johnny901114/4513242
Welcome reprinted: http://blog.csdn.net/johnny901114/article/details/7841685