我可以使用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