How to replace a view after I've inflated?
I have built my interface by using ViewStubs, which I inflate during onCreate.
But later in my app, I want t开发者_开发知识库o change the View completely, by loading different View into the same place. How do I achieve that?
Remove the old View
via removeView()
. Then inflate and add the replacement via addView()
.
Though if you're going to be bouncing back and forth a lot, consider using a FrameLayout
or ViewFlipper
or something to have both views loaded at once, only making one visible.
精彩评论