how to do a button click in Xamarin Forms Android custom info window
<p>In my <code>Xamarin Forms Android</code> project I am showing a <code>Map</code> using <code>CustomMapRenderer</code>. I am popping up a <code>Info Window</code> in Map screen and this info window has button name called <code>"Call"</code>. I need to do a <code>"OnCLick"</code> button click operation for this button. I have googled it, but unfortunately I didn't come across any solutions. at last I have started to work on converting the <code>Android Native code -</code><strong>Java</strong> into <code>Xamarin Forms Android -</code> <strong>c#</strong>, for this conversion I have been using this answers <a href="https://stackoverflow.com/questions/14123243/google-maps-android-api-v2-interactive-infowindow-like-in-original-android-go/15040761#15040761">Google Maps Android API v2 - Interactive InfoWindow (like in original android google maps)</a> . This converted code shows <code>A field initializer cannot reference the non static field, method or property OnInfoWindowElemTouchListener.onClickConfirmed(view, marker)</code> this <strong>Error</strong> inside <code>Java.Lang.Runnable</code> please help me to resolve the problem.</p>

<p><strong>OnInfoWindowElemTouchListener.cs</strong></p>

<pre><code> using System.Threading.Tasks;
    using Android.App;
    using Android.Content;
    using Android.Gms.Maps.Model;
    using Android.Graphics.Drawables;
    using Android.OS;
    using Android.Views;
    using Android.Views.Accessibility;

    using Java.Lang;

    namespace Hotel.Droid
    {
        public abstract class OnInfoWindowElemTouchListener : Java.Lang.Object
        , View.IOnTouchListener
        {
            private View view;

            private Drawable bgDrawableNormal;
            private Drawable bgDrawablePressed;
            private Handler handler = new Handler();
            private Marker marker;
            private static bool endPressStatus = false;
            private bool pressed = false;


            public OnInfoWindowElemTouchListener(View view, Drawable bgDrawableNormal, Drawable bgDrawablePressed)
            {
                this.view = this.view;
                this.bgDrawableNormal = this.bgDrawableNormal;
                this.bgDrawablePressed = this.bgDrawablePressed;
            }
            public OnInfoWindowElemTouchListener()
            {

            }

            public void setMarker(Marker marker)
            {
                this.marker = this.marker;
            }



            public bool OnTouch(View vv, MotionEvent e)
            {
                if (0 &lt;= e.GetX() &amp;&amp; e.GetX() &lt;= vv.Width &amp;&amp; 0 &lt;= e.GetY() &amp;&amp; e.GetY() &lt;= vv.Height)
                {
                    switch (e.ActionMasked)
                    {
                        case MotionEventActions.Down:
                            startPress();
                            break;

                        // We need to delay releasing of the view a little so it shows the
                        // pressed state on the screen
                        case MotionEventActions.Up:
                            //handler.PostDelayed(ConfirmClickRunnable, 150);
Task.Factory.StartNew(() =&gt; onClickConfirmed(view, marker));
Task.Delay(150);
                            break;

                        case MotionEventActions.Cancel:
                            endPress();
                            break;
                        default:
                            break;
                    }
                }
                else {
                    // If the touch goes outside of the view's area
                    // (like when moving finger out of the pressed button)
                    // just release the press
                    endPress();
                }

                return false;
            }


            private void startPress()
            {
                if (!pressed)
                {
                    pressed = true;
                    //handler.RemoveCallbacks(ConfirmClickRunnable);
                    view.SetBackgroundDrawable(bgDrawablePressed);
                    if ((marker != null))
                    {
                        marker.ShowInfoWindow();
                    }

                }

            }

            public bool endPress()
            {
                if (pressed)
                {
                    this.pressed = false;
                    handler.RemoveCallbacks(ConfirmClickRunnable);
                    view.SetBackgroundDrawable(bgDrawableNormal);


                    if ((marker != null))
                    {
                        marker.ShowInfoWindow();
                    }
                    endPressStatus = true;
                    return true;
                }
                else {
                    endPressStatus = false;
                    return false;
                }

            }

            private  Runnable ConfirmClickRunnable = new Java.Lang.Runnable(() =&gt;
            {
               if (endPressStatus)
               {

                    onClickConfirmed(view, marker);
               }
            });




            /*private  class RunnableAnonymousInnerClassHelper : Java.Lang.Object, Java.Lang.IRunnable
            {
                private readonly Context outerInstance;     

                public RunnableAnonymousInnerClassHelper(Context outerInstance)
                {
                    this.outerInstance = outerInstance;         
                }

                public void Run()
                {
                    if (endPressStatus)
                    {
                        onClickConfirmed();
                    }
                }
            }*/


            protected abstract void onClickConfirmed(View v, Marker marker);


        }

    }
</code></pre>

<p><a href="https://i.stack.imgur.com/xTtCw.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xTtCw.jpg" alt="enter image description here"></a></p>

<p><strong>Updated</strong></p>

<p>I have implemented the <code>Task.Factory.StartNew</code> instead of <code>Android Runnable</code>and now I am stucking on the below lines. I am struggling on converting this below <code>Java</code> codes into <code>C#</code>since it is written by <code>Anonymous</code> class concept. </p>

<p><strong>Java</strong></p>

<pre><code>this.infoButtonListener = new OnInfoWindowElemTouchListener(infoButton,
                getResources().getDrawable(R.drawable.btn_default_normal_holo_light),
                getResources().getDrawable(R.drawable.btn_default_pressed_holo_light)) 
        {
            @Override
            protected void onClickConfirmed(View v, Marker marker) {
                // Here we can perform some action triggered after clicking the button
                Toast.makeText(MainActivity.this, marker.getTitle() + "'s button clicked!", Toast.LENGTH_SHORT).show();
            }
        }; 
        this.infoButton.setOnTouchListener(infoButtonListener);
</code></pre>

<p><strong>infoButton</strong> in code is Call button</p>

<p>C# - Please help me to resolve the problem by converting/using(How to use) the above java code</p>