/** This is where we do the meat of creating our alert, which includes adding controls, etc. */ @Override public void draw(CGRect rect) { // if the control hasn't been setup yet if (activityIndicator == null) { // if we have a message if (message != null || !message.isEmpty()) { lblMessage = new UILabel(makeRect(20, 10, rect.size.width - 40, 33)); lblMessage.setBackgroundColor(UIColor.CLEAR); lblMessage.setTextColor(UIColor.LIGHT_TEXT_COLOR); lblMessage.setTextAlignment(UITextAlignment.CENTER); lblMessage.setText(message); addSubview(lblMessage); } // instantiate a new activity indicator activityIndicator = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.WHITE); activityIndicator.setFrame( makeRect( (rect.size.width / 2) - (activityIndicator.getFrame().size.width / 2), 50, activityIndicator.getFrame().size.width, activityIndicator.getFrame().size.height)); addSubview(activityIndicator); activityIndicator.startAnimating(); } super.draw(rect); }