Пример #1
0
  /** 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);
  }
Пример #2
0
 /**
  * We use this to resize our alert view. doing it at any other time has weird effects because of
  * the lifecycle
  */
 @Override
 public void layoutSubviews() {
   super.layoutSubviews();
   // resize the control
   setFrame(makeRect(getFrame().origin.x, getFrame().origin.y, getFrame().size.width, 120));
 }