In my game I have to let player input some double byte character, So I think use Android Widgets like EditText and Button is a good choice.
This is my View class:
public class TextInputView : LinearLayout
{
Android.Widget.Button _bt;
Android.Widget.EditText _te;
public TextInputView(Context context, View v)
: base(context)
{
_bt = new Android.Widget.Button(context);
_te = new Android.Widget.EditText(context);
_bt.Text = "OK";
_bt.Click += delegate
{
Game1.Activity.SetContentView(v);
};
AddView(_te);
AddView(_bt);
}
}
In my Activity class:
public class Activity1 : Microsoft.Xna.Framework.AndroidGameActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
Game1.Activity = this;
var g = new Game1();
View gameView = g.Window;
g.Run();
TextInputView inputView = new TextInputView(this,gameView);
Game1.View = inputView;
SetContentView(gameView);
}
}
In my Game1 class, I use SetContentView(Game1.View);
It’s works fine, TextInputView shows up, but when I click button want switch back to game, I got a black screen.