Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

SwipeGestureRecognizer Not Working Inside ListView Android #4628

Open
daves1992 opened this issue Dec 4, 2018 · 16 comments
Open

SwipeGestureRecognizer Not Working Inside ListView Android #4628

daves1992 opened this issue Dec 4, 2018 · 16 comments
Labels
a/listview Problems with the ListView/TableView e/5 🕔 5 p/Android t/bug 🐛

Comments

@daves1992
Copy link

daves1992 commented Dec 4, 2018

Description

SwipeGestures on a ViewCell in Android don't work and they break ContextActiions

 <ViewCell>
                            <ViewCell.ContextActions>
                                <MenuItem Command="{Binding Source={x:Reference CPMobileOrderPage}, Path=BindingContext.RemoveProductCommand}" CommandParameter="{Binding .}" Text="Delete" IsDestructive="True"/>
                            </ViewCell.ContextActions>
                            <ViewCell.View>
                                <Frame BackgroundColor="LightGray" Padding="1.5" HasShadow="False" CornerRadius="0">
                                    <Frame.GestureRecognizers>
                                        <SwipeGestureRecognizer Direction="Up" Command="{Binding Source={x:Reference CPMobileOrderPage}, Path=BindingContext.MoveProductUpList}" CommandParameter="{Binding .}"/>
                                        <SwipeGestureRecognizer Direction="Down" Command="{Binding Source={x:Reference CPMobileOrderPage}, Path=BindingContext.MoveProductDownList}" CommandParameter="{Binding .}"/>
                                    </Frame.GestureRecognizers>
                                    <Grid Padding="5,8,5,8" BackgroundColor="White">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="*"/>
                                            <ColumnDefinition Width="Auto"/>
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"/>
                                        </Grid.RowDefinitions>
                                        <Label Text="{Binding ID}" FontSize="Small" FontAttributes="Bold" TextColor="{Binding Source={x:Reference CPMobileOrderPage}, Path=BindingContext.DefaultPageDetailColor}" Grid.Column="0" Grid.Row="0" VerticalTextAlignment="Center"/>
                                    </Grid>
                                </Frame>
                            </ViewCell.View>
                        </ViewCell>

I have a Page where I have a switch and a Listview with items in. If I swipe the items with the switch enabled I can move them around. This works great on IOS. The SwipeGestureRecognizers are attached to the Frame inside the ViewCell.

Android the SwipeGestureRecognizer doesn't seem to work. It also seems to break the ContextActions and the binding for SelectedItem.

  • Version with issue: 3.4.0.1008975

  • IDE: Visual Studio 2017 15.9.3

  • Platform Target Frameworks:

    • iOS: 12.1
    • Android: 8.1
  • Android Support Library Version: 27.0.2

  • Affected Devices:
    Galaxy S9+

BrokenSwipeGes.zip

@kingces95
Copy link
Contributor

I'm able to run your reproduction but I'm not entirely clear what your actual and expected behaviors are. When you say "move them around" what exactly do you mean? I'm able to move them with the switch thrown either way on iOS and neither on Android. So that is different but before digging in I'd like to know what you expect. A video would be helpful. Or if you could reduce the reproduction further. Maybe start with a blank project and add the minimum code necessary to demonstrate the problem.

@kingces95 kingces95 added the s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. label Dec 5, 2018
@kingces95 kingces95 moved this from New to Needs Info in Triage Dec 5, 2018
@daves1992
Copy link
Author

daves1992 commented Dec 6, 2018

What I meant was as you described. On IOS I can swipe up and down on a viewcell arranging items in a list (using the SwipeGestureRecognizer's commands bound to two methods in the viewmodel which move items up and down the list). On Android I can't the items stay static. Ill create a new project and try to replicate with minimum code.

@daves1992
Copy link
Author

daves1992 commented Dec 6, 2018

Attached a new repro.

ListSwipeGes.zip

If you run the app you will get a listview. Swipe up on any item they should move up the list. Swipe down they should move down.

Android this doesn't happen. The context actions in android also don't work when there is a SwipeGestureRecognizer attached to anything in the viewcell. IOS swipe right and left you get the delete option. Android hold pressing an item usually you get the delete option at the top.

@bojanmisic
Copy link

I'm experiencing the same issue. If I use SwipeGestureRecognizer on a ContentPage, if I have ScrollView or ListView inside that page (with only vertical scrolling behavior), left and right swipes are not detected only on Android device. Emulator works fine, iOS both the device and the simulator are also OK.

@samhouts samhouts removed the s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. label Dec 6, 2018
@samhouts samhouts moved this from Needs Info to New in Triage Dec 6, 2018
@PureWeen PureWeen moved this from New to Ready For Work in Triage Dec 10, 2018
@PureWeen
Copy link
Contributor

@bojanmisic can you elaborate on your ScrollView use case over here?
#4552

I have a repro attached to that issue where I'm able to swipe in a ScrollView
If you can modify that repro? Or elaborate so we can reproduce that would be really helpful

@samhouts samhouts removed this from Ready For Work in Triage Dec 11, 2018
@msangtarash
Copy link

I have the same problem.
I have a Listview inside a Stcklayout. when i use SwipeGestureRecognizer on the stacklayout its leftswipe and rightswipe doesn't work on Android , but that is working fine on iOS and UWp

@vasuthakker
Copy link

Please update and resolve bug asap in android platform.

@vasuthakker
Copy link

Any update on the issue, when it will be fixed ?

@D4rkC1own187
Copy link

Why was this close? It has not been resolve.

@BoutemineOualid
Copy link

Any updates on this?

1 similar comment
@ivanxamarin032019
Copy link

Any updates on this?

@samhouts samhouts added the a/listview Problems with the ListView/TableView label Feb 24, 2020
@guilhermereisti
Copy link

Any updates on this? Still happening at XF 4.6.0.847 just on Android.

@samhouts samhouts added this to the 5.0.0 milestone Aug 13, 2020
@samhouts samhouts added this to To do in vNext+1 (5.0.0) Aug 14, 2020
@samhouts samhouts removed this from the 5.0.0 milestone Nov 2, 2020
@stephenhauck
Copy link

Anyone ... I "assumed" this would work ... it's 2021 ....

@stephenhauck
Copy link

Here is how to do it and have it work ...
image

@dasunmax89
Copy link

its not working still. XF 5.0.0.2196

@stephenhauck
Copy link

@dasunfit89 stop waiting for them to fix it and use the suggestion above.
Move to a CollectionView

@PureWeen PureWeen removed their assignment Aug 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a/listview Problems with the ListView/TableView e/5 🕔 5 p/Android t/bug 🐛
Projects
Development

No branches or pull requests