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.
Unfortunately, activation email could not send to your email. Please try again.

ScrollState event for SfListview (Android only)

Thread ID:

Created:

Updated:

Platform:

Replies:

131863 Jul 31,2017 05:07 PM Aug 2,2017 10:24 PM Xamarin.Forms 2
loading
Tags: SfListView
Emil
Asked On July 31, 2017 05:07 PM

I am having problems to download images within listview when user scrolls very fast. for that there is workaround in xamarin android listview.

_myListView.ScrollStateChanged += (object sender, ScrollStateChangedEventArgs scrollArgs) =>
{
  switch (scrollArgs.ScrollState)
  {
    case ScrollState.Fling:
      ImageService.SetPauseWork(true); // all image loading requests will be silently canceled
      break;
    case ScrollState.Idle:
      ImageService.SetPauseWork(false); // loading requests are allowed again
 
      // Here you should have your custom method that forces redrawing visible list items
      _myListView.ForcePdfThumbnailsRedraw();
      break;
  }
};



I saw on other component from telerik suggests this workaround 

http://www.telerik.com/forums/expose-scrollstate-event-to-list

Can we get something similar on SfListView please? 
thanks,

Emil

Emil
Replied On August 1, 2017 02:27 PM

I add native renderer in droid project as below. If i use xamarin forms listview, OnElementChanged is hit but using sflistview doesnt. is sflistview not inherited from xf listview? 

I cant find any OnElementChanged event in sflistview also. please let me know how can this be achieved


using Android.Widget;

using FFImageLoading;

using myapp.Droid.Rendrers;

//using ScrollList.Droid.Adapters;

using Xamarin.Forms;

using Xamarin.Forms.Platform.Android;

//using AndroidListView = Android.Widget.ListView;


[assembly: ExportRenderer(typeof(Xamarin.Forms.ListView), typeof(NativeListViewRenderer))]


namespace myapp.Droid.Rendrers

{

    public class NativeListViewRenderer : ListViewRenderer

    {

        public NativeListViewRenderer()

        {

        }


        protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.ListView> e)

        {

            base.OnElementChanged(e);


            if (Control == null)

                return;


            var listView = Control as global::Android.Widget.ListView;

            listView.ScrollStateChanged += (object sender, AbsListView.ScrollStateChangedEventArgs scrollArgs) => {

                switch (scrollArgs.ScrollState)

                {

                    case ScrollState.Fling:

                        ImageService.Instance.SetPauseWork(true); // all image loading requests will be silently canceled

                        break;

                    case ScrollState.Idle:

                        ImageService.Instance.SetPauseWork(false); // loading requests are allowed again


                        // Here you should have your custom method that forces redrawing visible list items

                        //_myListView.ForcePdfThumbnailsRedraw();

                        break;

                }

            };

        }

    }

}


Dinesh Babu Yadav [Syncfusion]
Replied On August 2, 2017 10:24 PM

Hi Emil, 
 
We are validating the reported requirement “Need for ScrollChanged state in SfListView for ScrollView” at our end and we need some additional information’s regarding the requirement to update you an appropriate solution. So, could you please share that you need to find whether the scrolling state as ScrollView is in scrolling or not, else additionally do you need any other state in SfListView for ScrollView? If yes, could you please provide additional information about the scrolling state which you required at your end? 
 
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.

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.

;