First of all I want to say that I'm really new to C# and Monogame in general.
My problem is with displaying a screen. I have a layout resource called loadingsplash.xml and want to show it while the Game activity is running LoadContent();
Flow diagram is: Main.xml: on button press > ProgressDialog during LoadContent > GameActivity
Flow diagram I want: Main.xml: on button press > show loadingsplash.xml during LoadContent > GameActivity
MainMenu.cs
[Activity( Label = "theApp", Theme = "@android:style/Theme.NoTitleBar.Fullscreen", MainLauncher=true, ScreenOrientation=Android.Content.PM.ScreenOrientation.Landscape)]
public class MainMenu : Activity, IDialogInterfaceOnClickListener
{
......
void GoButton_Click(object sender, EventArgs e)
{
Intent theActivity = new Intent(this, typeof(GameActivity));
StartActivity(theActivity);
}
theActivity.cs
namespace theApp
{
[Activity(Theme = "@android:style/Theme.NoTitleBar.Fullscreen", Label = "theApp", Icon = "@drawable/icon", ScreenOrientation = Android.Content.PM.ScreenOrientation.Landscape, ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.Keyboard | ConfigChanges.KeyboardHidden)]
public class GameActivity : Microsoft.Xna.Framework.AndroidGameActivity, IDialogInterfaceOnClickListener
{
myGame game = null;
static GameBundle gameBundle = null;
ProgressDialog dialog;
const int WindowID = 10001;
protected override void OnCreate(Bundle bundle)
{
loadedOnce = true;
//this works
//
//dialog = new ProgressDialog(this);
//dialog.SetMessage("Loading...");
//dialog.Show();
//
//Loading Splash screen invocation code goes here?
if (game == null)
{
myGame.Activity = this;
base.OnCreate (bundle);
game = new myGame();
game.NativeCommand = ProcessCommand;
game.Window.GraphicsMode = new AndroidGraphicsMode(0, 4, 0, 0, 0, false);
game.Window.Id = WindowID;
if (gameBundle == null)
{
game.Run();
}
else
{
if (gameBundle != null)
{
resumeGame.Show();
}
}
}
SetContentView(game.Window);
}
myGame.cs
public class myGame : Microsoft.Xna.Framework.Game
{
public myGame()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Resources/Drawable";
unloading = false;
graphics.PreferMultiSampling = true;
graphics.IsFullScreen = true;
graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft;
}
protected override void Initialize()
{
graphics.SynchronizeWithVerticalRetrace = true;
graphics.PreferredBackBufferWidth = 800;
graphics.PreferredBackBufferHeight = 480;
screenManager = new ScreenManager(this, 800, 480);
base.Initialize();
}
bool loaded = false;
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(this.GraphicsDevice);
font = Content.Load<SpriteFont>("Arial");
GraphicsDevice.Clear(Color.Black);
ThreadPool.QueueUserWorkItem(state =>
{
...
loaded = true;
});
If I invoke the LoadingSplash with setContentView(Resource.Layout.LoadingSplash); before base.OnCreate(bundle) I get an exception with requestFeature must be called.