How to display a busy indicator till the DataGrid is loading in Xamarin.Android?
Xamarin DataGrid takes some time for its initial loading of data and it largely depends on the type and size of the bound data. Thus, you can load an animation in the meantime the grid is loading using a SfBusyIndicator in the SfDataGrid.GridLoaded event.
Refer the below code in which a busy indicator is created and displayed until the SfDataGrid is loaded.
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView (Resource.Layout.Main); viewModel = new ViewModel(); dataGrid = new SfDataGrid(this); busyIndicator = new SfBusyIndicator(this); dataGrid.ItemsSource = viewModel.Collection; dataGrid.ColumnSizer = ColumnSizer.Star; dataGrid.GridLoaded += DataGrid_GridLoaded; frameLayout = FindViewById<FrameLayout>(Resource.Id.frameLayout); frameLayout.AddView(dataGrid); } private async void DataGrid_GridLoaded(object sender, GridLoadedEventArgs e) { busyIndicator.IsBusy = true; busyIndicator.ViewBoxHeight = 100; busyIndicator.ViewBoxWidth = 100; busyIndicator.AnimationType = AnimationTypes.SingleCircle; busyIndicator.Title = "Loading..."; busyIndicator.TextSize = 50; frameLayout.AddView(busyIndicator); await Task.Delay(5000); busyIndicator.IsBusy = false; busyIndicator.Visibility = Android.Views.ViewStates.Invisible; }
When the above code is executed, the output is obtained as follow:
Sample Link:
How to display a busy indicator till the SfDataGrid is loading
Conclusion
I hope you enjoyed learning about how to display a busy indicator till the DataGrid is loading in Xamarin.Android.
You can refer to our Xamarin.Android DataGrid feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!