开发者

Using two viewstubs in one layout in android

I am using viewstub for layout inflating in android. How can i use two viewstubs in one layou开发者_C百科t for inflating two different layouts?


You just have to place a second ViewStub into your layout file, as you probably did with your first one. Just give it a different id. Then you can reference the second one in code like you did with the first one (just using the different id) and inflate the second layout that you specified as a parameter in your layout file.

But if you want to inflate 2 different layouts in the same place, it's better to get a reference to a single ViewStub in code and use ViewStub.setLayoutResource() to change the layout file that will be inflated.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜