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.
CodePudding user response:
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: