Ok that prompts a few questions: 1) Can you elaborate on your last sentence: "But that's true within an activity only." Are you saying that the identifier is the id plus the activity? I have 2 different activities (on 2 tabs, actually).
2) How do you share a layout and use it multiple times, then? If the id is set in XML, and you have multiple instances, won't they save and restore state incorrectly, then? 3) What about the items within a ListView? Don't the all have the same id(s)? Wouldn't this cause a problem when saving their state? Or does the ListView do something magic to prevent such a problem? On May 7, 1:54 am, Romain Guy <[email protected]> wrote: > It's ok except when you need the views to save theirstate. The id is > what identifies views when theirstateis saved so the toolkit simply > think that your two list views are the same. But that's true within an > activity only. > > > > On Wed, May 6, 2009 at 11:44 AM, Toph <[email protected]> wrote: > > > Yes they do, but is that wrong? I thought it was ok to have multiple > > views with the same id. They are part of 2 different activities that > > share a common layout. > > > On Apr 27, 10:17 pm, Romain Guy <[email protected]> wrote: > >> Your two list views probably have the same id. > > >> On Sat, Apr 25, 2009 at 11:00 AM, Chris <[email protected]> wrote: > > >> > Hi, > > >> > I have TabActivity that uses 2 other ListActivities for the tabs. > >> > Both underlying ListViews are set to CHOICE_MODE_MULTIPLE. > >> > When I run the following sequence of events, I get a strange result: > >> > 1) Setup one activity (tab) and itsListViewusing a CursorAdapter, > >> > including checking some items on the list > >> > 2)Reorientthescreen(openthekeyboard) > >> > 3) Setup the second activity (tab) and itsListViewusing a > >> > CursorAdapter, including checking some items on the list > >> > 4) Switch back to the first tab > > >> > At this point, I can see in Eclipse that although (of course) each > >> >ListViewis a distinct object, the internal variable used to store the > >> >checkedstateof items, called mCheckStates, is the SAME OBJECT > >> > REFERENCE in each of the ListViews. > > >> > Clearly this is an issue, since the two views should not share the > >> >checkedstateof items between them. > > >> > If I skip step #2, this does not occur > > >> > Here is a bit more detail: > >> > After Step 1: ListView1 is object reference @1, ListView1.mCheckStates > >> > is object reference @2 > >> > After Step 2: ListView1 is object reference @3, ListView1.mCheckStates > >> > is object reference @4 (the reorientation recreates the views) > >> > After Step 3: ListView2 is object reference @5, ListView1.mCheckStates > >> > is object reference @2 <-- note the reuse of this reference from step > >> > #1, not sure how/why > >> > After Step 4: ListView1 is object reference @3 (unchanged), > >> > ListView1.mCheckStates is object reference @2 (changed) <-- same as > >> > ListView2.mCheckStates > > >> > Please help > > >> > Thanks > > >> -- > >> Romain Guy > >> Android framework engineer > >> [email protected] > > >> Note: please don't send private questions to me, as I don't have time > >> to provide private support. All such questions should be posted on > >> public forums, where I and others can see and answer them > > -- > Romain Guy > Android framework engineer > [email protected] > > Note: please don't send private questions to me, as I don't have time > to provide private support. All such questions should be posted on > public forums, where I and others can see and answer them --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

