android - Orientation change: children of LinearLayout can't have @+id/something -


cross posting android google group

i ran issue earlier today: https://code.google.com/p/android/issues/detail?id=55106

the problem is:

  • linearlayout has children
  • every child inflated same xml layout file
  • a child has nested element id.
    • the id used call findviewbyid(id) set value
  • everything displayed on startup, after orientation change every child of linearlayout displays value of last data item
  • as id removed child xml layout file, starts working properly

the bug has sample project attached demonstrates problem.

just wanted ask if has experienced same issue , knows workaround?

thank in advance.


edit:

the situation linearlayout pretty flaky. made project work - see second attached project @ https://code.google.com/p/android/issues/detail?id=55106

if go item_main.xml , change android:textisselectable false true, bug shows up. keep android:textisselectable="true", remove android:id="@+id/text" - bug disappears again

the main reason experimenting linearlayout because wanted follow thy layout animation sample. http://developer.android.com/training/animation/layout.html

but seems situation unstable linearlayout , orientation change need go working listview+adapter approach , figure out how similar layout animations when adding items adapter , revalidating list.

another workaround removing views linearlayout in onsaveinstancestate method.

@override protected void onsaveinstancestate(bundle outstate) {     linearlayout linearlayout = (linearlayout) findviewbyid(r.id.yourlinearlayoutid);     linearlayout.removeallviews();     super.onsaveinstancestate(outstate); } 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -