I'm using ispulltorefreshenabled to refresh a list. The list gets refreshed and stops when it finishes (by setting IsRefreshing = false), so everything works fine.
Thing is: when the list is refreshing, the loading spinner is not spinning. It just gets 'stuck' during this process.
How to get the refreshing spinner keep spinning while the list is refreshed?
the problem here is visible: the spinner is not spinning.
This is because the time of loading data is too little. You could add a little delay to make the spinner spin observiously.
private async void method(object obj) { for (var x = 0; x < 500; x++) { models.Add(new _Model { Content = "Item_" + x }); await Task.Delay(5); } listView.IsRefreshing = false; }
Answers
How did you achieve the refresh function? Try to set binding to the RefreshCommand and wait the data to be loaded.
Check the code:
Page.xaml
Page.xaml.cs
Using await Task.Delay() works, but the spinner is now spinning for 2 seconds before freezing. Sometimes loading takes one 1 second, sometimes it takes 5 seconds.
How to manage that?
Add the loading data code before
listView.IsRefreshing = false;
.I have a method that gives the list an update, how to insert that in you code?
I posted a basic demo you coul refer to the code.
It's also not spinning in your example.
It works but only spins a very little time because loading data doesn't require much time.
If you want the spinning to be obvious, you could add a delay to make that.
I also implemented your demo code in my code (where it takes a few seconds to load) and it still gets stuck.
Could you share a basic demo to reproduce the issue?
No not possible. Now I'm using Acr.UserDialogs to show loading when refreshing. I created a method and when a button is clicked or OnAppearing(), this method is refreshing the list. No I want to change that by a Pull-To-Refresh gesture. This works, but the loading spinner is simply not spinning.
Do you mean the data is updated when pulling to refresh? But the spinner doesn't spin?
Did you use the spinner and the UserDialogs both? I test the code with the plugin, it also works well.
Indeed. The list does update, but the spinner doesn't spin.
I use UserDialogs for other things, but not for this. I really want to have the spinner.
Please post the related code or share a bais demo to reproduce the issue, it'll help to get a solution.
Hi @YelinZh
I used the demo given earlier to create a demo where you can see my issue. 5000 new items are added each time you refresh the list. In the real app I don't have that much lines, but the problem here is visible: the spinner is not spinning.
Tested on physical Samsung Galaxy S10.
This is because the time of loading data is too little. You could add a little delay to make the spinner spin observiously.
I understand the solution, its just very difficult to implement this in my code. So I have to think about that one.