2

我有一个包含 n 个组的可扩展列表视图。每个组包含单个子项,其中包含不同数量的 textview,例如,第 1 组的子项包含 10 个 textview,第 2 组的子项包含 4 个 textview 等。我的问题是,当我在展开第 2 组子项时显示第 1 组的注释(Textviews)时也显示相同的注释。谁能告诉我如何区分孩子组或将不同的项目添加到不同的孩子?

对不起,我不能在这里粘贴完整的代码

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;
}

}

4

0 回答 0