Java implements OnClickListener, OnTouchListener how these processes can not find easily while the mono? Thank you in advance …
public class MyClass implements OnClickListener, OnTouchListener {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
break;
case MotionEvent.ACTION_UP:
break;
default:
break;
}
return false;
}
@Override
public void onClick(View v) {
}
}
How do I make this process a mono?
A literal translation of that sample to C# and Mono for Android would look like this:
While it is still possible to write your apps this way, following the Java conventions, there are nicer ways to do it in Mono for Android. In most cases where Java uses listener interfaces, Mono for Android will actually provide an event you can handle, which is much easier to use (and more C#-friendly). In this example you’d want to handle the
TouchandClickevents on a view: