Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Activity Spinner execution

$
0
0

I am trying to get an activity spinner to show up on the screen while I execute a process. I found code for an activity note based on the UIAlert and it comes up and closes correctly, ythe problem is it does not show to the user until the process is complete, kind of defeats the purpose. I am sure I just have the call to show it in the wrong place.

I have attached it to a login button as shown below, the 'LoadingView' is the activity class. The button is created in the 'FinishedLaunching' section of my AppDelegate.

`var loginButton = new StringElement ("Login", delegate {

            LoadingView LAV = new LoadingView(); 
            LAV.Show ("Verifying Credentials..."); 

            login.FetchValue ();
            pass.FetchValue ();

            if (LoginUser(login.Value, pass.Value)){

                _numberFailedLoginAttempts=0;
                NSUserDefaults.StandardUserDefaults.SetBool (true, "loggedIn");
                LAV.Hide(); 
                MakeInitialOptionsPage();

            }else{

                LAV.Hide(); 
                _numberFailedLoginAttempts++;
                NSUserDefaults.StandardUserDefaults.SetBool (false, "loggedIn");
                new UIAlertView ("Unknown Username or Password", "Unknown User", null, "ok", null).Show ();

            }
        });`

The LoadingView class `public class LoadingView : UIAlertView { private UIActivityIndicatorView _activityView;

    public void Show(string title) 
    { 
        Title = title; 

        _activityView = new 
                            UIActivityIndicatorView(UIActivityIndicatorViewStyle.WhiteLarge); 
        _activityView.Frame = new 
                              System.Drawing.RectangleF(122,50,40,40); 
        AddSubview(_activityView); 
        InvokeOnMainThread(delegate() { 
            _activityView.StartAnimating(); 
        }); 

        UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true; 

        Show(); 
    } 

    public void Hide() 
    { 

        UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false; 
        DismissWithClickedButtonIndex(0, true); 
    } 
} `

Any help would be greatly appreciated.

Cheers


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>