locked
how to display activity indicator RRS feed

  • Question

  • User307939 posted

    I need to display an activity indicator while navigation or while calling an ApI...how to implement it?

    Friday, April 7, 2017 6:44 AM

All replies

  • User2148 posted

    I suggest to use https://github.com/aritchie/userdialogs

    the "Loading" method...

    Friday, April 7, 2017 7:25 AM
  • User76049 posted

    @KavyaS

    Forms also has a built in Activity indicator.

    <StackLayout HeightRequest="40" VerticalOptions="End"> <ActivityIndicator IsRunning="{Binding Busy}" IsVisible="{Binding Busy}" HeightRequest="40" VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand"> <ActivityIndicator.WidthRequest> <OnPlatform x:TypeArguments="x:Double" iOS="100" Android="100" WinPhone="400" /> </ActivityIndicator.WidthRequest> <ActivityIndicator.Color> <OnPlatform x:TypeArguments="Color" iOS="#2499CE" WinPhone="#2499CE" /> </ActivityIndicator.Color> </ActivityIndicator> </StackLayout>

    Friday, April 7, 2017 8:14 AM
  • User180523 posted

    Personally I like the rg.plugins.popups package for popups. And you can make a "BusyPopup" to reuse for the needs you describe. That way you can have a semi-transparent busy indicator on top of your page to act as a barrier; keeping people from banging on buttons while the app is busying handling REST calls and so on.

    Friday, April 7, 2017 11:26 AM
  • User243969 posted

    @ClintStLaurent how you use it?

    Tuesday, May 2, 2017 3:40 PM
  • User2148 posted

    @RefkaBenmahmoud if you go to rg.plugin's github site you find some samples

    Tuesday, May 2, 2017 3:43 PM
  • User326962 posted

    @AlessandroCaliaro said: I suggest to use https://github.com/aritchie/userdialogs

    the "Loading" method...

    but how to display progress before calling Api and hide it after finishing calling Api I did the following UserDialogs.Instance.ShowLoading(); before calling api and UserDialogs.Instance.HideLoading(); after calling api

    but nothing happened, the action happened after clicked event has been finished. so if i removed this line "UserDialogs.Instance.HideLoading()" the progress will appear

    what shall i do ?!

    Monday, July 10, 2017 11:21 AM
  • User2148 posted

    you should post your code.

    Is it an async / await code?

    I usually use something like

    using (UserDialogs.Instance.Loading("wait...")) {
    
        // Do something 
    }
    
    Monday, July 10, 2017 11:27 AM
  • User38995 posted

    @AlessandroCaliaro said: you should post your code.

    Is it an async / await code?

    I usually use something like

    using (UserDialogs.Instance.Loading("wait...")) {

      // Do something 
    

    }

    Does not work for me, it simply does not appear. Do you have any suggestions?

    Thursday, January 4, 2018 12:10 PM
  • User171749 posted

    @TamasMatrai said:

    @AlessandroCaliaro said: you should post your code.

    Is it an async / await code?

    I usually use something like

    using (UserDialogs.Instance.Loading("wait...")) {
    
        // Do something 
    }
    

    Does not work for me, it simply does not appear. Do you have any suggestions?

    Have you also installed the package in your iOS and Android projects? and have you added this line into your Droids MainActivity.cs?

    UserDialogs.Init(this);

    Thursday, January 4, 2018 1:43 PM
  • User38995 posted

    @seanyda said:

    @TamasMatrai said:

    @AlessandroCaliaro said: you should post your code.

    Is it an async / await code?

    I usually use something like

    using (UserDialogs.Instance.Loading("wait...")) {

      // Do something 
    

    }

    Does not work for me, it simply does not appear. Do you have any suggestions?

    Have you also installed the package in your iOS and Android projects? and have you added this line into your Droids MainActivity.cs?

    UserDialogs.Init(this);

    Thanks :) I forgot it!

    Thursday, January 4, 2018 1:45 PM
  • User261326 posted

    Hi, someone who can tell me how to use Arc in Xamarin.Form, I get an error in MainActivity

    protected override void OnCreate(Bundle bundle) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; UserDialogs.Init(this); base.OnCreate(bundle); DevExpress.Mobile.Forms.Init();

            global::Xamarin.Forms.Forms.Init(this, bundle);
    
    
            LoadApplication(new App());
    
        }
    
    Friday, March 2, 2018 11:49 AM
  • User180523 posted

    @"VictorRangel.4469" Please don't hijack other people's threads just because it kinda, sorta has a couple words that maybe sorta sounds like your question.

    Please start your own question.

    Friday, March 2, 2018 12:00 PM
  • User373406 posted

    Hi i am using public interface IProgress { void Show(string message); void Hide(); }

    [assembly:Dependency(typeof(Progress))] namespace MyDemo.Droid.DependencyServices { public class Progress : IProgress { public void Hide() { AndHUD.Shared.Dismiss(); }

        public void Show(string message)
        {
            AndHUD.Shared.Show(Forms.Context, message);
        }
    }
    

    }

    and i use like that

        private  void Orders(IAuthorizationContext authContext)
        {
    
                    DependencyService.Get<IProgress>().Show(loading....);
                    DependencyService.Get<IProgress>().Hide();
        }
    

    but it not show the speeing wheel some time

    Monday, September 3, 2018 3:14 PM
  • User180523 posted

    @sarveshs What part of Don't hijack other people's threads posted right above where you posted - did you not understand? Maybe you are new to the internet or forums such as this so let me bring you up to speed: Doing that is considered very rude. Its the equivalent of jumping into a conversation other people are having and just taking it over for your own problems.

    Please start your own thread for your issue. Also, please use markdown to properly mark the code in your post so the site doesn't try to interpret it as something it should be rendering.

    FYI: If you read the documentation on ActivityIndicator you'll see it has to be raised from the Page currently being shown.

    @ClintStLaurent said: @"VictorRangel.4469" Please don't hijack other people's threads just because it kinda, sorta has a couple words that maybe sorta sounds like your question.

    Please start your own question.

    Tuesday, September 4, 2018 12:02 PM
  • User373406 posted

    @ClintStLaurent sorry for that

    Tuesday, September 4, 2018 12:28 PM
  • User379599 posted

    Probably late on this but have been battling with the activity thing for a long time and finally got it to work as follows: Rather than using the standard Xamarin ActivityIndicator (which will also work) I installed Nuget Acr.UserDialogs and used the ShowLoading and HideLoading methods (just cleaner code for lazy me). The trick was to put my long running task into a Task that is not part of the UI thread and here is some code that works great in a shared project, but only fully tested with Android (You have to do an init in MainActivity.cs for Android - Nuget readme gives you all that):

    My job kicks off with the user trying to register and hitting the button. So I made the button event handler async: (Excuse my ignoring Xamarin and C# naming conventions, been programming for 35 years so old habits die hard)

        //New user registration
        private async void btn2Confirm(object sender, EventArgs e)
        {
    

    //Here I do some input validation first and bail out if needed prior to calling my web client interface that takes the time

    //Start the busy thingy UserDialogs.Instance.ShowLoading("Checking");

    //Call a Task that checks on a server for database entries await createNewUser();

    //when done, hide the thingy UserDialogs.Instance.HideLoading();

    The task will set a string (friend variable to all in the class) called msg if anything goes wrong in order for the user to be informed if (msg != "") await DisplayAlert("Error", msg, "OK"); }

    //The task called is declared like this private async Task createNewUser() { await Task.Delay(250) .ContinueWith(task => { try {

                    //Here I do my calls to my version of an API using JSON stuff, and this normally takes a few seconds. If anything goes wrong, a message goes into var msg and task is terminated
                }
                          catch (Exception ex)
                          {
                              msg = ex.Message;
                          }
            });
    }
    

    Hope it's useful. First time I posted something

    Wednesday, November 14, 2018 2:57 PM