コード例 #1
0
  /**
   * Helper method to create a spinner for a field and insert it into the View container. This uses,
   * the String[] to create the list, and selects the value that is passed in from the list (the
   * features value). Can be used for domains as well as types.
   */
  Spinner createSpinnerViewFromArray(View container, Field field, Object value, String[] values) {

    TextView fieldAlias = (TextView) container.findViewById(R.id.field_alias_txt);
    Spinner spinner = (Spinner) container.findViewById(R.id.field_value_spinner);
    fieldAlias.setText(field.getAlias());
    spinner.setPrompt(field.getAlias());

    ArrayAdapter<String> spinnerAdapter =
        new ArrayAdapter<String>(this.context, android.R.layout.simple_spinner_item, values);
    spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(spinnerAdapter);
    // set current selection based on the value passed in
    spinner.setSelection(spinnerAdapter.getPosition(value.toString()));

    return spinner;
  }
コード例 #2
0
  /**
   * Helper method to create a date button, with appropriate onClick and onDateSet listeners to
   * handle dates as a long (milliseconds since 1970), it uses the locale and presents a button with
   * the date and time in short format.
   */
  Button createDateButtonFromLongValue(View container, Field field, long date) {

    TextView fieldAlias = (TextView) container.findViewById(R.id.field_alias_txt);
    Button dateButton = (Button) container.findViewById(R.id.field_date_btn);
    fieldAlias.setText(field.getAlias());

    Calendar c = Calendar.getInstance();
    c.setTimeInMillis(date);
    dateButton.setText(formatter.format(c.getTime()));

    addListenersToDatebutton(dateButton);

    return dateButton;
  }
コード例 #3
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;
  }