我可以使用正确的 groupcursors 和 childcursorsSimpleCursorTreeAdapter
创建。ExpandableListView
对于我的程序,每个孩子包含三个TextView
s。当我展开组并单击子项时,我使用自定义对话框在EditText
视图中显示三个值。
如果我一次只打开“一个”组,该程序就可以了。如果单击,我可以获得正确的子值。但是如果我同时扩展几个组。它只显示最新组下的最新孩子。
例如:A 组有 3 个项目,B 组有 5 个项目,C 组有 2 个项目。先点A组下的children,没问题,再点B组下的children,没问题,但是如果我回头再点击A组下的child,还是显示B组下的child,不知道怎么显示正确孩子们。如果我用Toast来展示,所有的孩子都是正确的,太奇怪了。我可以用这种方法做什么?
epView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener()
{
@Override
public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long row)
{
return false;
}
});
epView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id)
{
int tempid = childcursor.getInt(0);
String temp1 = childcursor.getString(1);
String temp2 = childcursor.getString(2);
String temp3 = childcursor.getString(3);
CustomDialog custom = new CustomDialog(ListCateActivity.this,catecursor,childcursor,temp1,temp2,temp3,tempid);
custom.setTitle("Record Information");
custom.show();
Toast.makeText(ListCateActivity.this, "Group:"+String.valueOf(groupPosition).toString()+" Child: "+String.valueOf(childPosition).toString()+temp1+" "+temp2+" "+temp3, Toast.LENGTH_SHORT).show();
return true;
}
});
谢谢 !!