Cross posting from Android Google group
I ran into this issue earlier today: https://code.google.com/p/android/issues/detail?id=55106
The problem is:
- LinearLayout has children
- every child is inflated from the same XML layout file
- a child has nested element with some ID.
- The ID is used to call findViewById(ID) to set some value
- Everything is displayed properly on startup, but after orientation change every child of LinearLayout displays the value of the last data item
- As soon as ID is removed from the child XML layout file, everything starts working properly
The bug has the sample project attached that demonstrates the problem.
Just wanted to ask if somebody has experienced the same issue and knows a workaround?
Thank you in advance.
EDIT:
The situation with LinearLayout is pretty flaky. I finally made the project work - see the second attached project at https://code.google.com/p/android/issues/detail?id=55106
If you go to item_main.xml and change android:textIsSelectable from false to true, the bug shows up. Keep android:textIsSelectable="true", but remove android:id="@+id/text" - the bug disappears again
The main reason I was experimenting with this LinearLayout is because I wanted to follow thy layout animation sample. http://developer.android.com/training/animation/layout.html
But it seems the situation is so unstable with LinearLayout and orientation change that I need to go back to the working ListView+Adapter approach and figure out how to do similar layout animations when adding items to the adapter and revalidating the list.