简体   繁体   中英

C# Monodroid Event Handlers

How do I operate the event handlers in C# Monodroid using:

m_listView.OnTouchEvent += OnTouchEvent;

It doesn't work as it would for a button or an item, and it gives an error:

"Cannot Assign to OnTouchEvent because it is a method group".

Like choper said that method is one you would override on a custom view. To subscribe to the touch event you should use Touch instead:

        m_listView.Touch += HandleTouch;
    }

    void HandleTouch (object sender, View.TouchEventArgs e)
    {
        // e.Event => MotionEvent
    }

It's not event at all, it just a method so the code that you provided should not work at all. You can override this method if you create custom ListView but you can not subscribe on it as on an event

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM