立即响应按钮。点击

时间:2017-01-12 21:16:40

标签: c# android xamarin

我想制作一个按钮,当你把手指放在它上面时会立即响应。

Button b1=FindViewById<Button>(Resource.Id.b1);

b1.Click += delegate {
            m1.SeekTo(0);
            m1.Start();
        };

当您将手指从按钮上移开时,这样做是为了获得响应(事件正在开启)。

1 个答案:

答案 0 :(得分:1)

你应该使用Touch事件。

示例:

private void Btn_Touch(object sender, Android.Views.View.TouchEventArgs e)
{
    if (e.Event.Action == Android.Views.MotionEventActions.Down)
    {
        //do something immediately after touch the button
    }
    if (e.Event.Action == Android.Views.MotionEventActions.Up)
    {
        //do something after placing off your finger

    }

}