简体   繁体   中英

How to show e message alert when data load and auto close when data is loaded - xamarin

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.

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:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM