We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Multiple tap events / listview

Thread ID:

Created:

Updated:

Platform:

Replies:

145038 Jun 3,2019 09:23 PM UTC Jul 12,2019 10:49 AM UTC Xamarin.Forms 13
loading
Tags: SfListView
James English
Asked On June 3, 2019 09:23 PM UTC

Hi,

I've got a Sflistview which contains several elements (labels, stacklayouts etc) all which have their own tapgesturerecognizer in order to perform specific commands.

This all works perfectly on iOS meaning I can use the listview's selected / drag & drop and swipe left / right features alongside my custom tapgesturerecognizers.

On Android this is not the case.  

The custom tapgesturerecognizers all work however, the layouts with these tapgesturerecognizers will not perform the listViews other events such as selected / drag & drop and swipe left / right.  I have to find an area of the listview item which  does not have a custom tapgesturerecognizer in order to use the listview features (drag / drop / swipe left & right).

I know the issue of Android / tap gestures being difficult to work with but has anyone got a solution for working around this issue?



Gnana Priya Namasivayam [Syncfusion]
Replied On June 4, 2019 12:51 PM UTC

Hi James, 
 
Thanks for using Syncfusion product. 
 
We would like to inform you that when gesture is added to child (say ItemTemplate), touch will not be passed to parent (say Listview). Therefore, SfListview events related to swiping, dragging, Tapped, doubled are not fired. This is the framework behavior and Xamarin Listview also behaves in same way in Android & iOS. We have currently logged a bug report to Xamarin team. You can track the status of the bug report from the below link. 
 
 
Regards, 
Gnana Priya N 


James English
Replied On June 5, 2019 08:29 AM UTC

Hi,

As mentioned, this all works perfectly on iOS, it is only an issue for Android.

Subburaj Pandian Veluchamy [Syncfusion]
Replied On June 6, 2019 12:42 PM UTC

Hi James, 
  
Sorry for the inconvenience caused. 
  
We would like to inform you that when you add gesture to the child element (say Grid) 'Touch' will be handled only by child (Grid) when loaded inside the Itemtemplate and will not transfer to the parent (SfListView). This behavior is common to both Android and iOS. We have attached the tested sample for your reference which has common behavior in Android and iOS when add gesture to one of the child elements, please find the sample from below. 
  
  
Please check the sample and let us know if you still facing the same issue? If not, please modify the sample based on your scenario and revert us with the more details, since we are not sure about how your sample works in iOS. It will be helpful for us to check on it and provide you the appropriate solution at the earliest.  
 
Regards,
Subburaj Pandian V 


James English
Replied On June 10, 2019 01:07 PM UTC

Hi,

This is code for the DataTemplates and how we use the SfListView which works only for iOS:

            <DataTemplate x:Key="iOSPlatformTemplate">
                <ViewCell>
                    <StackLayout Orientation="Horizontal" Padding="4,4,2,2" Spacing="0" BackgroundColor="White">
                        <StackLayout HorizontalOptions="FillAndExpand" Spacing="4">
                            <StackLayout.GestureRecognizers>
                                <TapGestureRecognizer Command="{Binding Path=ViewListItem, Source={x:Reference MyPageXaml}}" CommandParameter="{Binding .}" />
                            </StackLayout.GestureRecognizers>                             
                           
                            <StackLayout HorizontalOptions="FillAndExpand" Spacing="4">                         

                                <StackLayout IsVisible="{Binding Photo, Converter={StaticResource ImagePlaceholder}" Orientation="Horizontal" HeightRequest="85" MinimumWidthRequest="140" WidthRequest="140" BackgroundColor="#F8F9F9">
                                    <StackLayout.GestureRecognizers>
                                        <TapGestureRecognizer Command="{Binding Path=AddPhoto, Source={x:Reference MyPageXaml}}" CommandParameter="{Binding .}" />
                                    </StackLayout.GestureRecognizers>
                                    <StackLayout VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand">
                                        <Image Source="camera.png" />
                                        <Label Text="Add photo" FontSize="Small" TextColor="Gray" />
                                    </StackLayout>
                                </StackLayout>

                                <Label Text="Tap to add&#xA;name" IsVisible="{Binding name, Converter={StaticResource DisplayNamePlaceholder}}" TextColor="Gray" FontSize="Small" FontAttributes="Italic" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
                                    <Label.GestureRecognizers>
                                        <TapGestureRecognizer Command="{Binding Path=TapName, Source={x:Reference MyPageXaml}}" CommandParameter="{Binding .}" />
                                    </Label.GestureRecognizers>
                                </Label>

                            </StackLayout>
                    </StackLayout>
                </ViewCell>
            </DataTemplate>
            
            <DataTemplate x:Key="AndroidPlatformTemplate">
                <ViewCell>                   
                    <StackLayout Orientation="Horizontal" Padding="4,4,2,2" Spacing="0" BackgroundColor="White">
                        <StackLayout HorizontalOptions="FillAndExpand" Spacing="4">
                            <StackLayout.GestureRecognizers>
                                <TapGestureRecognizer Command="{Binding Path=ViewListItem, Source={x:Reference MyPageXaml}}" CommandParameter="{Binding .}" />
                            </StackLayout.GestureRecognizers> 

                            <StackLayout IsVisible="{Binding Photo, Converter={StaticResource ImagePlaceholder}" Orientation="Horizontal" HeightRequest="85" MinimumWidthRequest="140" WidthRequest="140" BackgroundColor="#F8F9F9">
                                <StackLayout.GestureRecognizers>
                                    <TapGestureRecognizer Command="{Binding Path=AddPhoto, Source={x:Reference MyPageXaml}}" CommandParameter="{Binding .}" />
                                </StackLayout.GestureRecognizers>
                                <StackLayout VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand">
                                    <Image Source="camera.png" />
                                    <Label Text="Add photo" FontSize="Small" TextColor="Gray" />
                                </StackLayout>
                            </StackLayout>

                            <Label Text="Tap to add&#xA;name" IsVisible="{Binding name, Converter={StaticResource DisplayNamePlaceholder}}" TextColor="Gray" FontSize="Small" FontAttributes="Italic" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
                                <Label.GestureRecognizers>
                                    <TapGestureRecognizer Command="{Binding Path=TapName, Source={x:Reference MyPageXaml}}" CommandParameter="{Binding .}" />
                                </Label.GestureRecognizers>
                            </Label>

                        </StackLayout>
                    </StackLayout>
                </ViewCell>
            </DataTemplate>

    <StackLayout BackgroundColor="#edeff0" Padding="0,10,0,0" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Spacing="0">
        <pulltoRefresh:SfPullToRefresh x:Name="pullToRefresh"
                                       ProgressBackgroundColor="Transparent"
                                       ProgressStrokeColor="Black"
                                       PullingThreshold="200"
                                       RefreshContentHeight="30"
                                       RefreshContentThreshold="30"
                                       RefreshContentWidth="30"                                       
                                       TransitionMode="Push"
                                       IsRefreshing="False" 
                                       Refreshing="RefreshList"
                                       HorizontalOptions="FillAndExpand"
                                       VerticalOptions="FillAndExpand">
            <pulltoRefresh:SfPullToRefresh.PullableContent>
                <syncfusion:SfListView AllowSwiping="true" ItemSpacing="0,1,0,0" ItemTemplate="{StaticResource PlatformSelector}" ItemSize="140" DragStartMode="OnHold"  SelectionMode="Single" ItemsSource="{Binding ListViewItems}" >

                    <syncfusion:SfListView.RightSwipeTemplate>
                      <DataTemplate x:Name="RightSwipeTemplate">
                        
                        <Grid BackgroundColor="#DC595F" HorizontalOptions="Fill" VerticalOptions="Fill">
                          <Grid VerticalOptions="Center" HorizontalOptions="Center">
                            <Image Grid.Column="0"
                                   Grid.Row="0"
                                   HeightRequest="35"
                                   WidthRequest="35"
                                   BackgroundColor="Transparent"
                                   Source="Delete.png" />
                          </Grid>
                        </Grid>
                      </DataTemplate>
                  </syncfusion:SfListView.RightSwipeTemplate>
                </syncfusion:SfListView>
            </pulltoRefresh:SfPullToRefresh.PullableContent>
        </pulltoRefresh:SfPullToRefresh>
    </StackLayout>


Subburaj Pandian Veluchamy [Syncfusion]
Replied On June 11, 2019 01:39 PM UTC

Hi James, 
  
We would like to inform you that to overcome the reported behavior in Android, we suggest you to use ItemTapped event of SfListview by removing the gesture added to StackLayout inside ItemTemplate like below which allows touch to pass both child and parent item. Please refer the following code for the same, 
  
  
<syncfusion:SfListView.ItemTemplate> 
   <DataTemplate> 
      <ViewCell> 
         <StackLayout Orientation="Horizontal" Padding="4,4,2,2" Spacing="0"BackgroundColor="White" > 
             <StackLayout HorizontalOptions="FillAndExpand" Spacing="4"> 
                     <!--<StackLayout.GestureRecognizers> 
                                <TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped"/> 
                          </StackLayout.GestureRecognizers>--> 
              </StackLayout> 
           </StackLayout> 
       </ViewCell> 
    </DataTemplate> 
</syncfusion:SfListView.ItemTemplate> 
  
  
We have attached the sample based on your code snippet for your reference, please find the sample from below. 
  
 
Please let us know whether above solution meets your requirement. 
 
Regards,
Subburaj Pandian V     


James
Replied On June 12, 2019 07:04 AM UTC

Hi,

This doesn't work with the SfListView drag and drop / slide left / slide right.

Please read my very first post....


I've got a Sflistview which contains several elements (labels, stacklayouts etc) all which have their own tapgesturerecognizer in order to perform specific commands.

This all works perfectly on iOS meaning I can use the listview's selected / drag & drop and swipe left / right features alongside my custom tapgesturerecognizers.

On Android this is not the case.  

The custom tapgesturerecognizers all work however, the layouts with these tapgesturerecognizers will not perform the listViews other events such as selected / drag & drop and swipe left / right.  I have to find an area of the listview item which  does not have a custom tapgesturerecognizer in order to use the listview features (drag / drop / swipe left & right).

I know the issue of Android / tap gestures being difficult to work with but has anyone got a solution for working around this issue?

Subburaj Pandian Veluchamy [Syncfusion]
Replied On June 13, 2019 01:50 PM UTC

Hi James, 
 
Thank you for the update. 
  
We are currently validating the reported query in our source with your application scenario from our side. We will validate and provide you the further details on or before June 17, 2019. We appreciate your patience until then. 
 
Regards,
Subburaj Pandian V 


Mageshyadav M [Syncfusion]
Replied On June 18, 2019 05:07 PM UTC

Hi James, 
  
We have got partial solution working for android similar to iOS but needs to validate with other cases hence we will get back to you with further details on June 19, 2019. 
  
Regards, 
Mageshyadav.M 


Mageshyadav M [Syncfusion]
Replied On June 21, 2019 12:35 AM UTC

Hi James, 
  
Sorry for repeated delays. 
  
We are still working on it and didn't get any possible complete solution which fits for all use cases hence it is taking time than usual. We will share you the next detail status for possible solution on Android on or before June 25, 2019. 
  
Regards, 
Mageshyadav.M 


Dinesh Babu Yadav [Syncfusion]
Replied On June 26, 2019 12:55 PM UTC

Hi James,                                                                                                                                               
 
Thanks for your patience. 
 
We would like to inform you that we have fixed the reported issue in android platform. The fix for the reported issue `SfListView events like dragging, swiping does not fire when gesture added to ItemTemplate in Android` will be included our upcoming weekly Nuget which is scheduled to be rolled out on July 9, 2019. We will appreciate your patience until then. 
 
Regards, 
Dinesh Babu Yadav 


James
Replied On July 2, 2019 10:48 AM UTC

Thanks for the update.  We came up with a work-around as we couldn't wait for a fix in the end.  I'll aim to give this a try in the future sometime.

Dinesh Babu Yadav [Syncfusion]
Replied On July 3, 2019 06:54 AM UTC

Hi James, 
 
Apologies for the inconvenience. 
 
As promised earlier, we will update you once the fix has been resolved and included in the release.  
 
Regards, 
Dinesh Babu Yadav 
 


Dinesh Babu Yadav [Syncfusion]
Replied On July 12, 2019 10:49 AM UTC

Hi James, 
 
We are glad to announce that our Essential Studio 2019 Volume 2 Release v17.2.0.34 is rolled out and is available for download under the following link. 
 
 
The fix for the bug SfListView events like dragging, swiping does not fire when gesture added to ItemTemplate in Android has been included in this release.  
 
We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance. 
 
Regards, 
Dinesh Babu Yadav 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon