コード例 #1
0
  /** {@inheritDoc} */
  public void onClick(View v) {
    // if this is not a list the plus button is not visible but the user might have clicked
    // the text.
    if (!mKind.isList) return;

    // Insert a new child and rebuild
    final ValuesDelta newValues = EntityModifier.insertChild(mState, mKind);
    this.rebuildFromState();
    this.updateAddEnabled();
    this.updateEditorsVisible();

    // Find the newly added EditView and set focus.
    final int newFieldId = mViewIdGenerator.getId(mState, mKind, newValues, 0);
    final View newField = findViewById(newFieldId);
    if (newField != null) {
      newField.requestFocus();
    }
  }
コード例 #2
0
  public void setState(DataKind kind, EntityDelta state, boolean readOnly, ViewIdGenerator vig) {
    mKind = kind;
    mState = state;
    mReadOnly = readOnly;
    mViewIdGenerator = vig;

    setId(mViewIdGenerator.getId(state, kind, null, ViewIdGenerator.NO_VIEW_INDEX));

    // TODO: handle resources from remote packages
    mTitle.setText(kind.titleRes);

    // Only show the add button if this is a list
    mAddPlusButton.setVisibility(mKind.isList ? View.VISIBLE : View.GONE);

    this.rebuildFromState();
    this.updateAddEnabled();
    this.updateEditorsVisible();
  }