/**
   * Return the updated FormEntry based on user changes at the given position.
   *
   * @param position
   * @return
   */
  public FormEntry getFormEntryAtViewPosition(int position, View row)
      throws IndexOutOfBoundsException {
    if (position < 0 || position > formArray.length)
      throw new IndexOutOfBoundsException("Given Adapter Position is out of bounds");

    FormEntry entry = formArray[position];
    entry.setReturnEntry(); // Tells the FormEntry that the time has come to look at the
    // updated values in the View Holder and save them.
    return entry;
  }
  /**
   * Returns the view at the given position. This is the method where we determine the type of form
   * to be used at each line and we pre-populate it with the current value in the Object.
   *
   * @param position
   * @param convertView can be null
   * @param parent
   * @return
   */
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View row = convertView;
    MyFormEntryViewHolder holder = null;
    FormEntry entry = formArray[position];
    LayoutInflater inflater = ((Activity) myContext).getLayoutInflater();

    if (row != null) holder = (MyFormEntryViewHolder) row.getTag();
    else {
      row = entry.getView(convertView, inflater, parent, myContext);
      row.setTag(holder);
    }
    return row;
  }
  public void setFormEntry(ArrayList<String> fieldTitles, int numRecords) {

    // for(int x=0; x<fieldTitles.size(); x++){
    formEntry.add(formEntry, fieldTitles, numRecords);
    // }

    for (int x = 0; x < numRecords; x++) {
      listModel.addElement((x + 1) + "");
    }

    ListSelectionModel listSelectionModel = list.getSelectionModel();
    listSelectionModel.addListSelectionListener(
        new ListSelectionListener() {

          @Override
          public void valueChanged(ListSelectionEvent e) {
            if (formEntry.getCurrentRecord() != list.getSelectedIndex())
              formEntry.setCurrentRecord(list.getSelectedIndex());
          }
        });
  }
 public void clearFormEntry() {
   formEntry.clear();
   listModel.clear();
   revalidate();
 }