开发者

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜