TB13
TB13

Reputation: 387

can it be possible to render different layout based on condition android?

I have a video application where having 1 teacher and maximum 6 students. So can i show or render different layout for different number of students like:

1 teache 1 student = layoyt_1 (from xml)
1 teache 2 student = layoyt_2 (from xml)
1 teache 3 student = layoyt_3 (from xml)
1 teache 4 student = layoyt_4 (from xml)
1 teache 5 student = layoyt_5 (from xml)
1 teache 6 student = layoyt_6 (from xml)

based on number of students can i set different xml or layout? Please help.

Upvotes: 1

Views: 651

Answers (1)

Android Developer
Android Developer

Reputation: 9643

You can use multiple ViewStubs in single layout where each ViewStub will contain layout for each condition and based on condition appropriate ViewStub is inflated!

ViewStub will be loaded only when you actually use it/need it(when setVisibility(int) or inflate() is invoked)

https://developer.android.com/reference/android/view/ViewStub

Upvotes: 1

Related Questions