I need use SetOnTouchListener:
LinearLayout cardLinearLayout = FindViewById<LinearLayout> (Resource.Layout.CardList);
cardLinearLayout.SetOnTouchListener (this);//Can't use THIS, must be argument with IOnTouchListener type. Where can I get this argument?
I want use it for ViewFlipper. Maybe other way exists.
In Xamarin.Android a lot of the Listener
interfaces have been converted to events
for more of a C# type of code.
So on all View
s there is a Touch
event which corresponds to the stuff happening in the OnTouchListener
.
However, if you really, really want to, you can implement the IOnTouchListener
interface like so:
public class MyOnTouchListener : Java.Lang.Object, View.IOnTouchListener
{
public bool OnTouch(View v, MotionEvent e)
{
/* do stuff */
}
}
And then use it on your LinearLayout
like so:
cardLinearLayout.SetOnTouchListener (new MyOnTouchListener());
You can compare that to the Touch
event, which only takes one line of code:
cardLinearLayout.Touch += (s, e) => { /* do stuff */ };
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With