开发者

How to replace a view after I've inflated?

开发者 https://www.devze.com 2022-12-24 16:43 出处:网络
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 plac

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消