@Override
  public void viewDidLoad() {
    super.viewDidLoad();

    getTableView().setSeparatorStyle(UITableViewCellSeparatorStyle.None);
    getTableView().setBackgroundColor(UIColor.black());

    getNavigationItem().setTitleView(new UIImageView(UIImage.getImage("TitleFindFriends")));

    if (getNavigationController().getViewControllers().first() == this) {
      UIBarButtonItem dismissLeftBarButtonItem =
          new UIBarButtonItem(
              "Back",
              UIBarButtonItemStyle.Plain,
              new UIBarButtonItem.OnClickListener() {
                @Override
                public void onClick(UIBarButtonItem barButtonItem) {
                  getNavigationController().dismissViewController(true, null);
                }
              });
      getNavigationItem().setLeftBarButtonItem(dismissLeftBarButtonItem);
    } else {
      getNavigationItem().setLeftBarButtonItem(null);
    }

    if (MFMailComposeViewController.canSendMail() || MFMessageComposeViewController.canSendText()) {
      headerView = new UIView(new CGRect(0, 0, 320, 67));
      headerView.setBackgroundColor(UIColor.black());
      UIButton clearButton = new UIButton(UIButtonType.Custom);
      clearButton.setBackgroundColor(UIColor.clear());
      clearButton.addOnTouchUpInsideListener(inviteFriendsButtonAction);
      clearButton.setFrame(headerView.getFrame());
      headerView.addSubview(clearButton);
      String inviteString = "Invite friends";
      CGRect boundingRect =
          NSString.getBoundingRect(
              inviteString,
              new CGSize(310, Float.MAX_VALUE),
              NSStringDrawingOptions.with(
                  NSStringDrawingOptions.TruncatesLastVisibleLine,
                  NSStringDrawingOptions.UsesLineFragmentOrigin),
              new NSAttributedStringAttributes().setFont(UIFont.getBoldSystemFont(18)),
              null);
      CGSize inviteStringSize = boundingRect.getSize();

      UILabel inviteLabel =
          new UILabel(
              new CGRect(
                  10,
                  (headerView.getFrame().getSize().getHeight() - inviteStringSize.getHeight()) / 2,
                  inviteStringSize.getWidth(),
                  inviteStringSize.getHeight()));
      inviteLabel.setText(inviteString);
      inviteLabel.setFont(UIFont.getBoldSystemFont(18));
      inviteLabel.setTextColor(UIColor.white());
      inviteLabel.setBackgroundColor(UIColor.clear());
      headerView.addSubview(inviteLabel);
      getTableView().setTableHeaderView(headerView);
    }
  }
 @IBAction
 public void toggleRecording() {
   if (!movieFileOutput.isRecording()) {
     recordButton.setImage(UIImage.create("player_stop"), UIControlState.Normal);
     startRecording();
   } else {
     recordButton.setImage(UIImage.create("player_record"), UIControlState.Normal);
     movieFileOutput.stopRecording();
     if (timer.isValid()) {
       timer.invalidate();
     }
   }
 }
  private void configureImageButton() {
    // To create this button in code you can use UIButton.create() with a
    // parameter value of UIButtonType.Custom.

    // Remove the title text.
    imageButton.setTitle("", UIControlState.Normal);

    imageButton.setTintColor(Colors.PURPLE);

    UIImage imageButtonNormalImage = UIImage.getImage("x_icon");
    imageButton.setImage(imageButtonNormalImage, UIControlState.Normal);

    // Add an accessibility label to the image.
    imageButton.setAccessibilityLabel("X Button");

    imageButton.addOnTouchUpInsideListener(this);
  }
  @Override
  public void didFinishLaunching(UIApplication application) {
    window = new UIWindow(UIScreen.getMainScreen().getBounds());
    window.makeKeyAndVisible();

    UIViewController viewController = new UIViewController();

    UIButton boton = new UIButton(new CGRect(10, 10, 200, 30));
    boton.setBackgroundColor(new UIColor(1, 0, 0, 0.5f));
    boton.setTitle("Send Mail", UIControlState.Normal);
    boton.addOnTouchUpInsideListener(
        new OnTouchUpInsideListener() {
          @Override
          public void onTouchUpInside(UIControl control, UIEvent event) {
            sendMail();
          }
        });
    viewController.setView(boton);

    window.setRootViewController(viewController);
  }
  private void configureAttributedTextSystemButton() {
    // Set the button's title for normal state.
    NSAttributedStringAttributes normalTitleAttributes =
        new NSAttributedStringAttributes()
            .setForegroundColor(Colors.BLUE)
            .setStrikethroughStyle(NSUnderlineStyle.StyleSingle);
    NSAttributedString normalAttributedTitle =
        new NSAttributedString("Button", normalTitleAttributes);

    attributedTextButton.setAttributedTitle(normalAttributedTitle, UIControlState.Normal);

    // Set the button's title for highlighted state.
    NSAttributedStringAttributes highlightedTitleAttributes =
        new NSAttributedStringAttributes()
            .setForegroundColor(Colors.GREEN)
            .setStrikethroughStyle(NSUnderlineStyle.StyleThick);
    NSAttributedString highlightedAttributedTitle =
        new NSAttributedString("Button", highlightedTitleAttributes);

    attributedTextButton.setAttributedTitle(highlightedAttributedTitle, UIControlState.Highlighted);

    attributedTextButton.addOnTouchUpInsideListener(this);
  }
  public MyViewController() {
    // Get the view of this view controller.
    UIView view = getView();

    // Setup background.
    view.setBackgroundColor(UIColor.white());

    // Setup label.
    label = new UILabel(new CGRect(20, 250, 280, 44));
    label.setFont(UIFont.getSystemFont(24));
    label.setTextAlignment(NSTextAlignment.Center);
    view.addSubview(label);

    // Setup button.
    button = UIButton.create(UIButtonType.RoundedRect);
    button.setFrame(new CGRect(110, 150, 100, 40));
    button.setTitle("Click me!", UIControlState.Normal);
    button.getTitleLabel().setFont(UIFont.getBoldSystemFont(22));

    button.addOnTouchUpInsideListener(
        new UIControl.OnTouchUpInsideListener() {
          @Override
          public void onTouchUpInside(UIControl control, UIEvent event) {
            System.gc();

            System.out.println(label.getText());
            label.setText("Click Nr. " + (++clickCount));

            if (tapjoyConnected) {
              launchTapjoy();
            } else {
              System.out.println("tapjoy not connected yet");
            }
          }
        });
    view.addSubview(button);
  }
 private void configureSystemDetailDisclosureButton() {
   systemDetailDisclosureButton.setBackgroundColor(UIColor.clear());
   systemDetailDisclosureButton.addOnTouchUpInsideListener(this);
 }
 private void configureSystemContactAddButton() {
   systemContactAddButton.setBackgroundColor(UIColor.clear());
   systemContactAddButton.addOnTouchUpInsideListener(this);
 }
 private void configureSystemTextButton() {
   systemTextButton.setTitle("Button", UIControlState.Normal);
   systemTextButton.addOnTouchUpInsideListener(this);
 }