Expandablelistview子项android

时间:2013-09-26 09:11:51

标签: android listview expandablelistview

我有一个expandablelistview,其中包含n个组。每个组包含单个子项,其中包含不同的textview计数,例如,组1的子项包含10个textview, 第2组儿童包含4个textview等。我的问题是,当我展示第1组的注释(Textviews)时,第2组儿童也会显示相同的注释。任何人都可以告诉我如何区分小组或不同的孩子的不同项目?

抱歉,我无法在此处粘贴完整代码

public class ExpandableListAdapter extends BaseExpandableListAdapter {

private Context mContext;
private ExpandableListView mExpandableListView;
private List<GroupEntity> mGroupCollection;
private int[] groupStatus;

 private ArrayList<HashMap<String, String>> data;

public ExpandableListAdapter(Context pContext,
        ExpandableListView pExpandableListView,
        List<GroupEntity> pGroupCollection, ArrayList<HashMap<String, String>> d, String jobID2 ,String userId, String totalTasks) {

    mContext = pContext;
    mGroupCollection = pGroupCollection;
    mExpandableListView = pExpandableListView;
    data=d;
    jobId =jobID2;
    groupStatus = new int[mGroupCollection.size()];
    totalNoTask=totalTasks;
    userKey=userId;
    setListEvent();
}

private void setListEvent() {

    mExpandableListView
            .setOnGroupExpandListener(new OnGroupExpandListener() {

                @Override
                public void onGroupExpand(int arg0) {
                    // TODO Auto-generated method stub
                    groupStatus[arg0] = 1;
                }
            });

    mExpandableListView
            .setOnGroupCollapseListener(new OnGroupCollapseListener() {

                @Override
                public void onGroupCollapse(int arg0) {
                    // TODO Auto-generated method stub
                    groupStatus[arg0] = 0;
                }
            });
}

@Override
public String getChild(int arg0, int arg1) {

    // TODO Auto-generated method stub

    return mGroupCollection.get(arg0).GroupItemCollection.get(arg1).Name;

}

@Override
public long getChildId(int arg0, int arg1) {
    // TODO Auto-generated method stub
    return 0;
}


@Override
public View getChildView(int arg0, int arg1, boolean arg2, View arg3,
        ViewGroup arg4) {

    // TODO Auto-generated method stub
    HashMap<String, String> song = new HashMap<String, String>();
    song = data.get(arg0);
    for (String key : song.keySet()) {
        String tId =key;
        String value = song.get("id");           
        taskID= value;
    }


    final EditText textView ;
    ImageButton imGbtn ;
    final ChildHolder childHolder;
    if (arg3 == null) {


    }   

    return arg3;
}

@Override
public int getChildrenCount(int arg0) {
    // TODO Auto-generated method stub
    return mGroupCollection.get(arg0).GroupItemCollection.size();
}

@Override
public Object getGroup(int arg0) {
    // TODO Auto-generated method stub
    return mGroupCollection.get(arg0);
}

@Override
public int getGroupCount() {
    // TODO Auto-generated method stub
    return mGroupCollection.size();
}

@Override
public long getGroupId(int arg0) {
    // TODO Auto-generated method stub
    return arg0;
}

}

0 个答案:

没有答案