I have Portable project in Visual Studio 2015 with a ListView
that gets populated with some data via an API call through the following function refreshData
:
async Task refreshData()
{
myListView.BeginRefresh();
var apiCallResult = await App.Api.myApiGetCall();
myListView.ItemsSource = apiCallResult;
myListView.EndRefresh();
}
refreshData()
is called in
protected override void OnAppearing()
{
base.OnAppearing();
refreshData();
}
Everything is working fine except on Android where the refresh indicator is not stopping or disappearing on EndRefresh()
when the page is initially loaded. The page is in a TabbedPage
so I can go to a different tab and then return to this page and the refresh indicator properly starts and stops with completion of my API call.
Why is refresh is not stopping when the page initially loads on Android? Any help would be appreciated.
Note: This works perfectly fine when I run on iOS.
So far I've tried:
replacing
myListView.BeginRefresh()
withmyListView.IsRefreshing = true
andmyListView.EndRefresh()
withmyListView.IsRefreshing = false
Using
Device.BeginInvokeOnMainThread(() => {//update list and endRefresh})
.Using
async void refreshData()
instead ofasync Task refreshData()
.
ListView
page under aTabbedPage
, it will refresh twice when the page is initialized, and if it is not under aTabbedPage
, it works fine. What you mean then by "not stop refresh"? Could you please share us a minimal reproducible demo? – ChretienListView
. When I load data it will be generally in the range of 0-10 items. – Restorative