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. Image for the cookie policy date

ScrollState event for SfListview (Android only)

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

2 Replies

EM Emil August 1, 2017 06:27 PM UTC

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;

                }

            };

        }

    }

}



DB Dinesh Babu Yadav Syncfusion Team August 3, 2017 02:24 AM UTC

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 


Loader.
Live Chat Icon For mobile
Up arrow icon