コード例 #1
0
  public ProductDescriptionView() {
    name = new UILabel();
    name.setText("Name");
    name.setBackgroundColor(Colors.Clear);
    name.setTextColor(Colors.Gray);
    name.setFont(UIFont.getSystemFont(25));
    name.setTranslatesAutoresizingMaskIntoConstraints(false);
    name.sizeToFit();
    addSubview(name);

    descriptionLabel = new UILabel();
    descriptionLabel.setBackgroundColor(Colors.Clear);
    descriptionLabel.setTextColor(Colors.LightGray);
    descriptionLabel.setTranslatesAutoresizingMaskIntoConstraints(false);
    descriptionLabel.setFont(UIFont.getSystemFont(14));
    descriptionLabel.setLineBreakMode(NSLineBreakMode.WordWrapping);
    descriptionLabel.setNumberOfLines(0);
    addSubview(descriptionLabel);

    price = new UILabel();
    price.setBackgroundColor(Colors.Clear);
    price.setText("Price");
    price.setTextColor(Colors.Blue);
    price.setTranslatesAutoresizingMaskIntoConstraints(false);
    price.sizeToFit();
    addSubview(price);
  }
コード例 #2
0
  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);
  }