Android tutorial _ using expandablelistview to implement a list of QQ friends

Source: Internet
Author: User

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




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.