My requirement is to handle a double tap in my Grid
control for Xamarin.Android
without using gestures. I already have a selection operation to be performed on a single click.
I have implemented the double tap logic in the OnSingleClick
event of the IOnSingleClick
interface. This is how it works: A single click will select the row of the grid and another single click will deselect the row of the grid.
So now when I want to double tap, I don't want the selection to happen. How can i achieve this ? I cant use the OnSingleTapConfirmed()
since the selection operation is handled in the key up event and hence a delay will happen which affects the user experience.
public void OnClick(View v)
{
long currentTouchTime = Java.Lang.JavaSystem.CurrentTimeMillis();
if (previousClickTime == 0 || (currentTouchTime - previousClickTime > 500))
{
previousClickTime = currentTouchTime;
//count = 0;
if (this.DataColumn != null && previousClickTime != 0)
{
Handler.PostDelayed(action, 500);
}
count = 1;
}
else
{
Toast.MakeText(this.Context, "Double Tapped", ToastLength.Short).Show();
}
}