Android QQ opening and closing table

Source: Internet
Author: User

QQ Suspension list function is not implemented temporarily

Main Xml

<relativelayout xmlns:android= "http://schemas.android.com/apk/res/android"    xmlns:tools= "http// Schemas.android.com/tools "    android:layout_width=" match_parent "    android:layout_height=" Match_parent "    tools:context= ". Activity.demo9activity ">    <expandablelistview        android:id=" @+id/demo9_expendablelistview "        Android:layout_width= "Match_parent"        android:layout_height= "Match_parent"/></relativelayout>

Adapter

public class Demo9adapter extends Baseexpandablelistadapter {private list<string> grouplist;//outer data source        Private list<list<string>> childlist;//layer of data source private context context; Public Demo9adapter (context context, list<string> grouplist,list<list<string>> childlist) {T            His.context = context;            This.grouplist = grouplist;        This.childlist = childlist;        } @Override public int getgroupcount () {return grouplist.size ();        }/** * This return must be the size of the list set in the corresponding outer item @param groupposition * @return */        @Override public int Getchildrencount (int groupposition) {return childlist.get (groupposition). Size ();        } @Override public Object getgroup (int groupposition) {return groupposition;    } @Override public Object getchild (int groupposition, int childposition) {        Return Childlist.get (groupposition). get (Childposition);        } @Override public long getgroupid (int groupposition) {return groupposition;        } @Override public long getchildid (int groupposition, int childposition) {return childposition;        } @Override public Boolean hasstableids () {return true; } @Override public View getgroupview (int groupposition, Boolean isexpanded, View Convertview, ViewGroup Pare            NT) {Convertview = View.inflate (context, r.layout.item_demo9_style1, null);            Group name TextView TextView = (TextView) Convertview.findviewbyid (r.id.group_name);            Number of child elements TextView # = (TextView) Convertview.findviewbyid (R.id.count);            Number.settext (Childlist.get (groupposition). Size () + "X");            Textview.settext (Grouplist.get (groupposition));        return convertview;       } @Override Public View getchildview (int groupposition, int childposition, Boolean islastchild, view view, ViewGroup ViewGroup) {            View = view.inflate (context, r.layout.item_demo9_style2, null);            TextView TextView = (TextView) View.findviewbyid (r.id.child_name);            The outer group name Textview.settext (Childlist.get (groupposition). Get (childposition));        return view;         } @Override public boolean ischildselectable (int groupposition, int childposition) {return true; }}

 main

 Private Expandablelistview Expandablelistview;    Private Demo9adapter Myadapter;    Private list<string> grouplist;    Private list<list<string>> childlist;        @Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);        Setcontentview (R.LAYOUT.ACTIVITY_DEMO9);    Initview (); }//group Suspension private void Initview () {Expandablelistview = (Expandablelistview) Findviewbyid (R.id.demo9_expendab        Lelistview);        Grouplist = new arraylist<> ();        Childlist = new arraylist<> ();        AddData ("Kindergarten classmate", New string[]{"Jay", "Dancing Dogs", "Ceria", "Gao Yuan Yuan", "Liu poem", "Liu Yifei", "Anglebaby", "Zhang Jing", "Zhang Yun",});        AddData ("Primary school classmate", new string[]{"Bald Strong", "Bear Big", "Bear II", "Miao Frog Seeds", "than the card Mound", "double egg gas", "snake"}); AddData ("Junior high school students", New string[]{"Akiho Yoshizawa Step", "Yui Hatano", "Love Chuan Mei Li", "Azomi", "Peach Valley painted in the incense", "The Old ze Lola", "Northern original more fragrant son", "Shichuan Shi Boon", "North article Ma Imperial Concubine", "hemp storehouse excellent", "Haneda Love", "        Baozan "});        AddData ("High school classmate", New string[]{"Qin Shi Huang", "Li Shimin", "Wu Zetian", "Caocao", "Liu Bei", "Sun Quan"}); AddData ("University classmate", New string[]{"Jay Chou"), "Dancing Dogs", "Ceria", "Gao Yuan Yuan", "Liu poem", "Liu Yifei", "Anglebaby", "the beginning of Zhang Jing", "Zhang Yun",});        AddData ("Graduate students", new string[]{"Bald Strong", "Bear Big", "Bear II", "Miao Frog Seeds", "than the card Mound", "double egg gas", "snake"});        AddData ("PhD students", New string[]{"Azomi", "Peach Valley painted in the incense", "The Old ze Lola", "the northern original more fragrant son", "Shichuan Grace", "The Northern Ma Imperial Concubine", "hemp Warehouse excellent", "Haneda Love", "Baozan Painting"});        AddData ("Professor colleague", New string[]{"Qin Shi Huang", "Li Shimin", "Wu Zetian", "Caocao", "Liu Bei", "Sun Quan"}); AddData ("The list of the Immortals", New string[]{"Cang jing Empty", "Maria Ozawa", "Akiho Yoshizawa Step", "Yui Hatano", "Chuan Mei Li", "Azomi", "Peach Valley painted in the incense", "The Old ze Lola", "North original more fragrant son", "Shichuan Shi Boon", "Northern Bar Concubine"        , "Ma Cang excellent", "Haneda Love", "Baozan painting", "Qin Shihuang", "Li Shimin", "Wu Zetian", "Caocao", "Liu Bei", "Sun Quan"});        Myadapter = new Demo9adapter (this,grouplist,childlist);             Expandablelistview.setadapter (myadapter);//First load all expand for (int i = 0; i < grouplist.size (); i++) {            if (i==0) {expandablelistview.collapsegroup (i);            }else {expandablelistview.expandgroup (i); }}//2, cannot click Shrink: Expandablelistview.setongroupclicklistener (New Expandablelistview.ongroupclicklistene R () {@Override publiC Boolean Ongroupclick (expandablelistview parent, View v, int groupposition, long I            d) {//TODO auto-generated method stub return false;        }        }); Long press event Expandablelistview.setoncreatecontextmenulistener (new View.oncreatecontextmenulistener () {@Overr IDE public void Oncreatecontextmenu (ContextMenu menu, View V, Contex Tmenu.contextmenuinfo menuinfo) {//TODO auto-generated Method Stub menu.setheadertitle ("Select                Operation ");//Download_retry Download_del Download_start menu.add (0,0, 0," retry ");                Menu.add (0, 1, 0, "delete");            Menu.add (0, 2, 0, "start");    }        });        }/** * method to add data */private void AddData (String Group, string[] friend) {Grouplist.add (group); Each item opens again a different List collection list<string> ChilDitem = new arraylist<> ();        for (int i = 0; i < friend.length; i++) {Childitem.add (friend[i]);    } childlist.add (ChildItem); }/** * Long Press Menu response function */@Override public boolean oncontextitemselected (MenuItem Item) {//TODO auto-g enerated method Stub//Key <span class= "Wp_keywordlink" style= "margin:0px; padding:0px; border:0px; background:transparent; " ><a target=_blank href= "http://www.xuebuyuan.com/" title= "code" target= "_blank" style= "text-decoration:none; Color:rgb (1, 150, 227); " > Code </a></span> Expandablelistview.expandablelistcontextmenuinfo info = (Expandablelistview.expandab        Lelistcontextmenuinfo) Item.getmenuinfo ();        int type = Expandablelistview.getpackedpositiontype (info.packedposition); if (type = = Expandablelistview.packed_position_type_child) {//The above type sets the judging of the types here!            This is child judgment! int grouppos = Expandablelistview.getpackedpositiongroup (info.packedposition); InChild judgment inside, get the child belongs to group! int childpos = Expandablelistview.getpackedpositionchild (info.packedposition);            In the child's judgment, get the child belongs to position! Switch (Item.getitemid ()) {case 0:toast.maketext (this, "I am retrying", Toast.length_short). Show (                    );//Maketextshort ("I am retrying");                Break                    Case 1:toast.maketext (This, "I am Delete", toast.length_short). Show ();                Break                Case 2:toast.maketext (This, "I am booting", toast.length_short). Show ();            Default:break;        } return true;    } return false; }

Data reference: http://blog.csdn.net/dl10210950/article/details/52525492

Android QQ opening and closing table

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.