my keyboard works when I am in main method.
I enter a child method and the keyboard does not work.
the same code works in c# windows.
I ported the code to C# xamarin.Android and i can not use the keyboard in the child method.
The window in the child method blanks out after 5 seconds.
I access the keyboard the same way in the main and child methods.
This is the c# code that calls the keyboard input in MainActivity:
static string Getchnow()
{
while (MainActivity.return_set == 1){ }
MainActivity.return_set = 1;
return MainActivity.scankeyinput;
}
This is the code that reads the keyboard input in MainActivity:
var textV_3 = FindViewById<TextView>(Resource.Id.textView3); // TODO Is this view needed?if not remove from MainActivity.cs and xml
var editV_1 = FindViewById<EditText>(Resource.Id.editText1);
//This code reads keypress from EditText View
editV_1.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) =>
{
keyboardInput = e.Text.ToString();
if (keyboardInput != "") // prevents crash doue to infinite EventChanged loop
{
scankeyinput = "";
// debugScanKeyInputLength = scankeyinput.Length; // DEBUG
keyboardInputLength = keyboardInput.Length;
if (keyboardInputLength > 0)
{
scankeyinput = keyboardInput.Substring(keyboardInput.Length - 1);
scankeychar = scankeyinput.ToCharArray(0, 1);
editV_1.SetText(scankeychar, 0, 0); // CLEARS EditView in a way that doesnot crash the app because it causes aTextChangedEvent
textV_3.Text = scankeyinput;
return_set = 0;
button_10.PerformClick(); //TODO should not be needed. //TODO Updating Screen is slow. Try a different approach to editing and commands.
}
}
};