我可以使用SimpleCursorTreeAdapter
创建ExpandableListView
与正确的groupcursors和childcursors。对于我的计划,每个孩子包含三个TextView
s。当我展开组并单击孩子时,我使用自定义对话框来显示EditText
视图中的三个值。得到正确的值childcursor点击组
如果我一次只打开“ONE”组,那么程序就可以。如果点击,我可以得到正确的子值。但如果我同时扩大几个小组。它只显示最新的小组下的最新的孩子。
例如:A组有3个项目,B组有5个项目,C组有2个项目。首先我点击了A组下的孩子,没问题,B组的孩子没问题,但是如果我回去点击A组下的孩子,它仍然显示B组下的孩子。我不知道如何显示正确儿童。如果我使用吐司来显示,所有的孩子都是正确的,很奇怪。我能用这种方法做什么?
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;
}
});
谢谢!!
我在做类似的东西这里http://stackoverflow.com/questions/10611927/simplecursortreeadapter-and-cursorloader – toobsco42 2012-05-16 07:25:18