Site feedback

joepuhich-9960 avatar image
0 Votes"
joepuhich-9960 Posted ·

Keyboard input c# xamarin.Android does not work in the child method

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.
                     }
                 }
             };






dotnet-android
· 2
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@joepuhich-9960 , thank you for the feedback. This area is for feedback on Microsoft Q&A feedback only. So we are closing this item.

0 Votes 0 ·

I am looking for info on C# xamarin.android phone.
is this the right area?

0 Votes 0 ·
joepuhich-9960 avatar image
0 Votes"
joepuhich-9960 Posted ·

what does dotnet mean?

10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

joepuhich-9960 avatar image
0 Votes"
joepuhich-9960 Posted ·

the emulator blanks out when I leave the main function.

I access OnDraw again.
The emulator does not redraw the screen.

I think the problem is OnDraw!!!
I Invalidate OnDraw as shown.

I think OnDraw should refresh the emulator when this method is called...

     public DrawnView(Android.Content.Context context) : base(context)
     {
     }
     protected override void OnDraw(Canvas canvas)
     {
         Invalidate();
         base.OnDraw(canvas);

         Paint paint = new Paint();
         paint.Color = Color.Blue;
         canvas.DrawPaint(paint);

         DrawnView.gridtext = Tester.gridtext;

         if (gridtext == "0")
         {
             Invalidate();

             paint.SetStyle(Paint.Style.Stroke);
             paint.StrokeWidth = 5f;
             paint.Color = Color.Black;
             paint.TextSize = 75;

             DrawnView.row1 = Tester.row1;
             DrawnView.row2 = Tester.row2;
             DrawnView.row3 = Tester.row3;
             DrawnView.row4 = Tester.row4;
             DrawnView.row5 = Tester.row5;
             DrawnView.row6 = Tester.row6;

             canvas.DrawText(row8, 0, 200, paint);
             canvas.DrawText(row9, 0, 300, paint);

// canvas.DrawText(messagechar, 0, 200, paint);
// canvas.DrawText(messagechar, 0, 300, paint);

             canvas.DrawText(row1, 0, 400, paint);
             canvas.DrawText(row2, 0, 500, paint);
             canvas.DrawText(row3, 0, 600, paint);
             canvas.DrawText(row4, 0, 700, paint);
             canvas.DrawText(row5, 0, 800, paint);
             canvas.DrawText(row6, 0, 900, paint);
         }
              }

10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

joepuhich-9960 avatar image
0 Votes"
joepuhich-9960 Posted ·

i can not get the keyboard to work in a child method...

10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Your Opinion Counts

Share your feedback, or help out by voting for other people's feedback.

Related Feedback