Hello, ViewFlipper doesn't help either because I still need to add the layout dynamically. The problem really comes down to this:
mInnerLayout = (LinearLayout) layout.inflate( R.layout.multiple_select, mContainerLayout); How can I add mInnerLayout to mContainerLayout after it has been removed? On Jan 30, 5:02 pm, Mark Murphy <mmur...@commonsware.com> wrote: > steele johnson wrote: > > I'm trying to dynamically swap in and out various layouts to one > > layout container. > > Option #1: go the path you are trying > > Option #2: use ViewFlipper or ViewSwitcher for parent container and have > it handle changing the children > > > > > I've instantiated the container layout (mContainerLayout) by finding > > it using the id through the maine Activity layout. This is successful. > > > Next, I add the inner layout by calling: > > > layoutInflater = this.getLayoutInflater(); > > > and then inflating the inner layout like this: > > > mInnerLayout = (LinearLayout) layoutInflater .inflate( > > R.layout.inner_layout, mContainerLayout); > > > This seems to work fine. I see the inner layout displayed in the > > Activity that holds the containing layout. Next, I want to swap in > > another inner layout, so I call: > > > mContainerLayout.removeAllViews(); > > > and then I repeat the steps above. This is successful as well. > > > The problem is when I try to swap in and out the instantiated layouts > > (the one that's returned from the inflate() call). When I call: > > > mContainerLayout.removeAllViews(); > > > and then call: > > > mContainerLayout.addView(mInnerLayout ); > > > I get a 'source not found' error. > > > My question is: how can I swap the Layouts that have already been > > instantiated? > > Try removing the single view representing the "inner layout" instead of > the whole view tree. In other words, use removeView() instead of > removeAllViews(). > > Personally, I typically just use ViewFlipper, so it can handle this > case, plus give me the option for animating the transition between child > views if I so choose. > > -- > Mark Murphy (a Commons Guy)http://commonsware.com > _The Busy Coder's Guide to Android Development_ Version 2.0 Available! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---