Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
360 views
in Technique[技术] by (71.8m points)

android - two different layouts for one activity

Is it possible to have two different layouts for different cases in the same activity or do I have to use intent to call another activity with a different layout

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Yes its possible. You can use as many layouts as possible for a single activity but obviously not simultaneously. You can use something like:

if (Case_A)
  setContentView(R.layout.layout1);

else if (Case_B)
  setContentView(R.layout.layout2);

and so on...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...