Issue
I want to show message alert when data is loading and auto close this message when data is loaded, because I have a too much data for displaying with this code:
private async Task GetAPI()
{
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri("https://crypto-news-live.p.rapidapi.com/news/coindesk"),
Headers =
{
{ "x-rapidapi-host", "crypto-news-live.p.rapidapi.com" },
{ "x-rapidapi-key", "51569aba99mshf9e839fcfce791bp16c0dbjsn9ced6dba7472" },
},
};
using (var response = await client.SendAsync(request))
{
var news = new News();
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
var newsBody = JsonConvert.DeserializeObject<List<NewsBody>>(body);
news.CryptoNews = newsBody;
lstNews.ItemsSource = newsBody;
}
}
Until the ListView is filled with data through the simulator wait between 5 and 7 seconds.
Solution
Yes, you can do it using Toast message plugin available for Xamarin.Forms.
When you are calling data load service just before that show a loader with message and when data loading is complete remove that loader that's it.
Check this blog for reference:
- https://theconfuzedsourcecode.wordpress.com/2018/03/19/build-yo-own-awesome-activity-loading-indicator-page-for-xamarin-forms/
- https://www.damirscorner.com/blog/posts/20201106-BusyOverlayInXamarinForms.html
Answered By - Divyesh_08
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.