コード例 #1
0
  /**
   * Helper method to add the field alias and the fields value into columns of a view using standard
   * id names. If the field has a length set, then this is used to constrain the EditText's
   * allowable characters. No validation is applied here, it is assumed that the container has this
   * set already (in XML).
   */
  View createAttributeRow(View container, Field field, Object value) {

    TextView fieldAlias = (TextView) container.findViewById(R.id.field_alias_txt);
    EditText fieldValue = (EditText) container.findViewById(R.id.field_value_txt);
    fieldAlias.setText(field.getAlias());

    // set the length of the text field and its value
    if (field.getLength() > 0) {
      InputFilter.LengthFilter filter = new InputFilter.LengthFilter(field.getLength());
      fieldValue.setFilters(new InputFilter[] {filter});
    }

    Log.d(AttributeEditorActivity.TAG, "value is null? =" + (value == null));
    Log.d(AttributeEditorActivity.TAG, "value=" + value);

    if (value != null) {
      fieldValue.setText(value.toString(), BufferType.EDITABLE);
    } else {
      fieldValue.setText("", BufferType.EDITABLE);
    }

    return fieldValue;
  }