Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Xamarin Forms WebView and GestureRecognizers not working with android

$
0
0

Hello,

I have created a webview to load my local HTML file. My application requires to load another HTML file as the user swipes right or left. I have created this functionality with the following code:

    <WebView
        x:Name="HtmlView"
        Grid.Row="1" 
        Source="{Binding HTMLFile}" 
        HorizontalOptions="FillAndExpand" 
        VerticalOptions="FillAndExpand"
        GoBackRequested="Handle_GoBackRequested"
        GoForwardRequested="Handle_GoForwardRequested"
        >
        <WebView.GestureRecognizers>
        <SwipeGestureRecognizer Direction="Left" Swiped="Handle_SwipedLeft"/>
        <SwipeGestureRecognizer Direction="Right" Swiped="Handle_SwipedRight"/>
        </WebView.GestureRecognizers>
    </WebView>

And Implemented the handlers as shown below:

    void Handle_SwipedLeft(object sender, Xamarin.Forms.SwipedEventArgs e)
    {
        flashCard.HTMLFile = getHTMLFileFromDevice("FlashCard2.html");
        HtmlView.Reload();
    }

    void Handle_SwipedRight(object sender, Xamarin.Forms.SwipedEventArgs e)
    {
        flashCard.HTMLFile = getHTMLFileFromDevice("FlashCard3.html");
        HtmlView.Reload();
    }

This works completely fine with iOS, however if try running it on android (using the emulator) the handlers are not called at all. Is there something that I am missing here?

Thanks


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>