Beispiel #1
0
  /**
   * Creates a new TextBoxBase component
   *
   * @param container container that the component will be placed in
   * @param textview the underlying EditText object that maintains the text
   */
  public TextBoxBase(ComponentContainer container, EditText textview) {
    super(container);

    view = textview;

    // Listen to focus changes
    view.setOnFocusChangeListener(this);

    defaultTextBoxDrawable = view.getBackground();

    // Add a transformation method to provide input validation
    /*
     * TODO(user): see comment above) setTransformationMethod(new
     * ValidationTransformationMethod());
     */

    // Adds the component to its designated container
    container.$add(this);

    container.setChildWidth(this, ComponentConstants.TEXTBOX_PREFERRED_WIDTH);

    TextAlignment(Component.ALIGNMENT_NORMAL);
    // Leave the nice default background color. Users can change it to
    // "none" if they like
    //
    // TODO(user): if we make a change here we also need to change the
    // default property value.
    // Eventually I hope to simplify this so it has to be changed in one
    // location
    // only). Maybe we need another color value which would be
    // 'SYSTEM_DEFAULT' which
    // will not attempt to explicitly initialize with any of the properties
    // with any
    // particular value.
    // BackgroundColor(Component.COLOR_NONE);
    Enabled(true);
    fontTypeface = Component.TYPEFACE_DEFAULT;
    TextViewUtil.setFontTypeface(view, fontTypeface, bold, italic);
    FontSize(Component.FONT_DEFAULT_SIZE);
    Hint("");
    Text("");
    TextColor(Component.COLOR_BLACK);
  }
Beispiel #2
0
  /**
   * Creates a new VideoPlayer component.
   *
   * @param container
   */
  public VideoPlayer(ComponentContainer container) {
    super(container);
    container.$form().registerForOnDestroy(this);
    videoView = new ResizableVideoView(container.$context());
    videoView.setMediaController(new MediaController(container.$context()));
    videoView.setOnCompletionListener(this);
    videoView.setOnErrorListener(this);
    videoView.setOnPreparedListener(this);

    // add the component to the designated container
    container.$add(this);
    // set a default size
    container.setChildWidth(this, ComponentConstants.VIDEOPLAYER_PREFERRED_WIDTH);
    container.setChildHeight(this, ComponentConstants.VIDEOPLAYER_PREFERRED_HEIGHT);

    // Make volume buttons control media, not ringer.
    container.$form().setVolumeControlStream(AudioManager.STREAM_MUSIC);

    sourcePath = "";
  }