質問

Usage of _id is not clear enough in my mind. Considering all possible actions(onChildClick,onItemClick,onExpand,onCollapse etc. or even drawings) on ExpandableListView below;

=A==============
   -B-----------
   -C-----------
=D==============
   -E-----------
   -B-----------    //Note: B is included in both groups

is it OK to use same _id values with CursorTreeAdapter on following relations:

  1. B with C (this is problem I know)
  2. A with D (this is problem too, I know)
  3. A with B (this is what I am confused)
  4. E with C (also this one confuses me)
  5. E with B (possible problem)
  6. C with D (OK, I guess)
役に立ちましたか?

解決

The _id simply has to be unique for any given category. In other words the parents (groups) must have a unique _id from each other and each individual child within a particular group should have a unique _id from each other but it doesn't matter if any have the same _id as a parent.

Using your example, groups A & D should not have the same _id.

In group A, children B & C should not have the same _id as each other but if one of them has the same _id as group A or group D then it doesn't matter.

In group D, children E & B should not have the same _id and, again, if one of them has the same _id as group A or group D this also doesn't matter.

Finally, child B in both groups can (and probably will) have the same _id in both instances.

In short, the CursorTreeAdapter requires a single Cursor for the groups and multiple separate Cursors for each set of children. None of these are directly related and each are self-contained.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top