问题描述
我不知道我怎么会一个活动中表现出2个不同的布局。我现在是等待被发现opponenets有一个多人游戏,我想有是有,而oppenent在后台被发现,当对手发现其他布局将出现出现一个载入画面
I was wondering how I could show 2 different layouts within one activity. I have a multiplayer game right now that waits for opponenets to be found and what I want to have is to have a loading screen that appears while the oppenent is being found in the background and when the opponent is found the other layout will show up
// Get animal & background selected by user
setContentView(R.layout.activity_pregame_selection_multi);
... ...
// Display the multiplayer screen
setContentView(R.layout.activity_multi_player);
然而,第一个布局犯规露面。只有黑屏
however the first layout doesnt show up. only a blank screen
推荐答案
您也可以简单地使用View.Gone和View.visible。
只是把上面的加载视图。使用View.visible上加载视图和View.Gone上的其他意见的根源。比,当加载或等待做法仅仅是做了加载视图和View.Visible就休息View.Gone。
You can also simply use View.Gone and View.visible.just put the loading view on top. use View.visible on the loading view and View.Gone on the root of the other views. than, when the loading or waiting is done simply do View.Gone on the loading view and View.Visible on the rest.
这篇关于设置两个布局一个活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!