set two layouts for one activity


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


I wouldn't play with the setContentView , it's too heavy for this simple operation. Just use a the "waiting" view on top of your wanted view, and play with the setVisibilty Visible/Gone.

If you find yourself in need of 2 setContentView you probably need 2 activities / fragments


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.


  • Creating a promise for accessing multiple datapoints from firebase using angular factory
  • Hide dynamically added buttons based on an if statement
  • Edit a variable within an array
  • Macro to cycle through and allocate data to members of structs incorrectly recognises struct member
  • Why does IEnumerable only have the “out” covariant flag and not “in” c#?
  • Confusion with collections of nested generics
  • How to increment div id with php for loop?
  • image captcha in php
  • Swift 3 Custom extension of ns measurement? Ex. Sheeps to goats
  • ZF2: How to get Zend\\Navigation inside custom route?
  • allocating memory to an array of string
  • How to load gif image while ajax content is loading and javascript [duplicate]
  • Android distinguish between tap and double tap
  • netsh acl setting (need alternative method - registry settings?)
  • Syntax error on tokens, AnnotationName expected instead - error on query
  • WPF version of .ScaleControl?
  • how do i write assembly code from c#?
  • How to get latest version of a artifact on Bintray using JSONP
  • Combining two different ActiveRecord collections into one
  • bad substitution shell- trying to use variable as name of array
  • Android Activity.onWindowFocusChanged doesn't get called from within TabHost
  • wxPython: displaying multiple widgets in same frame
  • Stop Bash Script if Hive Fails
  • C: Incompatible pointer type initializing
  • Google Custom Search with transparent background
  • Android fill_parent issue
  • Repeat a vertical line on every page in Report Builder / SSRS
  • Why value captured by reference in lambda is broken? [duplicate]
  • Obtain ObjectIdHex value from mgo query
  • Volusion's generic SQL folder, functionality
  • How to set/get protobuf's extension field in Go?
  • How to apply VCL Styles to DLL-based forms in Inno Setup?
  • JSON with duplicate key names losing information when parsed
  • Can I have the cursor start on a particular column by default in jqgrid's edit mode?
  • Rearranging Cells in UITableView Bug & Saving Changes
  • align graphs with different xlab
  • Circular dependency while pushing http interceptor
  • Linker errors when using intrinsic function via function pointer
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize