/** This method used to create dynamic form for group. */
  private void createForm() {
    LayoutInflater inflater = LayoutInflater.from(this);
    LinearLayout.LayoutParams params =
        new LinearLayout.LayoutParams(
            android.widget.LinearLayout.LayoutParams.MATCH_PARENT,
            android.widget.LinearLayout.LayoutParams.WRAP_CONTENT);
    params.topMargin = 10;

    LinearLayout layout = null;
    int size = IN_FIELD_LIST.size();
    for (int j = 0; j < size; j++) {
      final HashMap<String, String> field = IN_FIELD_LIST.get(j);
      View fieldView = inflater.inflate(R.layout.jom_dynamic_view_item, null);

      if (field.get(TYPE).equals(TEXT)) {
        final IjoomerEditText edit;
        layout = ((LinearLayout) fieldView.findViewById(R.id.lnrEdit));
        layout.setVisibility(View.VISIBLE);
        edit = ((IjoomerEditText) layout.findViewById(R.id.txtValue));
        edit.setText(Html.fromHtml(field.get(VALUE)));
        edit.setHint(field.get(CAPTION));
        if (field.get(NAME).equals(GROUPRECENTPHOTOS)
            || field.get(NAME).equals(GROUPRECENTVIDEOS)
            || field.get(NAME).equals(GROUPRECENTEVENTS)) {
          edit.setInputType(InputType.TYPE_CLASS_NUMBER);
        }
      } else if (field.get(TYPE).equals(TEXTAREA)) {
        final IjoomerEditText edit;
        layout = ((LinearLayout) fieldView.findViewById(R.id.lnrEditArea));
        layout.setVisibility(View.VISIBLE);
        edit = ((IjoomerEditText) layout.findViewById(R.id.txtValue));
        edit.setText(Html.fromHtml(field.get(VALUE)));
        edit.setHint(field.get(CAPTION));

      } else if (field.get(TYPE).equals(SELECT)) {
        layout = ((LinearLayout) fieldView.findViewById(R.id.lnrSpin));
        layout.setVisibility(View.VISIBLE);
        MyCustomAdapter adapter = IjoomerUtilities.getSpinnerAdapter(field);
        ((Spinner) layout.findViewById(R.id.txtValue)).setAdapter(adapter);
        ((Spinner) layout.findViewById(R.id.txtValue)).setSelection(adapter.getDefaultPosition());

      } else if (field.get(TYPE).equals(DATETIME)) {
        final IjoomerEditText edit;
        layout = ((LinearLayout) fieldView.findViewById(R.id.lnrEditClickable));
        layout.setVisibility(View.VISIBLE);
        edit = ((IjoomerEditText) layout.findViewById(R.id.txtValue));
        edit.setText(field.get(VALUE));
        edit.setHint(field.get(CAPTION));
        edit.setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(final View v) {
                IjoomerUtilities.getDateTimeDialog(
                    ((IjoomerEditText) v).getText().toString(),
                    new CustomClickListner() {

                      @Override
                      public void onClick(String value) {
                        ((IjoomerEditText) v).setText(value);
                        ((IjoomerEditText) v).setError(null);
                      }
                    });
              }
            });

      } else if (field.get(TYPE).equals(MULTIPLESELECT)) {
        final IjoomerEditText edit;
        layout = ((LinearLayout) fieldView.findViewById(R.id.lnrEditClickable));
        layout.setVisibility(View.VISIBLE);
        edit = ((IjoomerEditText) layout.findViewById(R.id.txtValue));
        edit.setText(field.get(VALUE));
        edit.setHint(field.get(CAPTION));
        edit.setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(final View v) {
                IjoomerUtilities.getMultiSelectionDialog(
                    field.get(CAPTION),
                    field.get(OPTIONS),
                    "",
                    new CustomClickListner() {

                      @Override
                      public void onClick(String value) {
                        ((IjoomerEditText) v).setText(value);
                      }
                    });
              }
            });
      } else if (field.get(TYPE).equals(MAP)) {
        final IjoomerEditText edit;
        final ImageView imgMap;
        layout = ((LinearLayout) fieldView.findViewById(R.id.lnrEditMap));
        layout.setVisibility(View.VISIBLE);
        edit = ((IjoomerEditText) layout.findViewById(R.id.txtValue));
        imgMap = ((ImageView) layout.findViewById(R.id.imgMap));
        edit.setText(field.get(VALUE));
        edit.setHint(field.get(CAPTION));
        imgMap.setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View v) {}
            });

      } else if (field.get(TYPE).equals(CHECKBOX)) {
        final IjoomerCheckBox chb;
        layout = ((LinearLayout) fieldView.findViewById(R.id.lnrCheckbox));
        layout.setVisibility(View.VISIBLE);
        chb = ((IjoomerCheckBox) layout.findViewById(R.id.txtValue));
        chb.setTextAppearance(JomGroupCreateActivity.this, R.style.ijoomer_textview_h2);
        if (field.get(NAME).equals(DISCUSSORDERING)
            || field.get(NAME).equals(GROUPDISCUSSIONFILESHARING)) {
          chb.setText(field.get(CAPTION) + " " + getString(R.string.group_discussion));
        } else if (field.get(NAME).equals(GROUPANNOUNCEMENTFILESHARING)) {
          chb.setText(field.get(CAPTION) + " " + getString(R.string.group_announcement));
        } else {
          chb.setText(field.get(CAPTION));
        }
        if (field.get(VALUE).toString().trim().length() > 0) {
          chb.setChecked(field.get(VALUE).toString().equals("1") ? true : false);
        }

        if (field.get(NAME).equalsIgnoreCase(PHOTOPERMISSION_MEMBER)
            || field.get(NAME).equalsIgnoreCase(VIDEOPERMISSION_MEMBER)
            || field.get(NAME).equalsIgnoreCase(EVENTPERMISSION_MEMBER)) {
          chb.setEnabled(false);
        }
        chb.setOnCheckedChangeListener(
            new OnCheckedChangeListener() {

              @SuppressWarnings({"unchecked"})
              @Override
              public void onCheckedChanged(CompoundButton IjoomerButtonView, boolean isChecked) {

                if (field.get(NAME).equalsIgnoreCase(PHOTOPERMISSION_ADMIN)) {
                  int size = lnr_form.getChildCount();
                  for (int i = 0; i < size; i++) {
                    View v = (LinearLayout) lnr_form.getChildAt(i);
                    HashMap<String, String> field = new HashMap<String, String>();
                    field.putAll((HashMap<String, String>) v.getTag());
                    IjoomerCheckBox chbValue =
                        (IjoomerCheckBox)
                            ((LinearLayout) v.findViewById(R.id.lnrCheckbox))
                                .findViewById(R.id.txtValue);
                    if (field.get(NAME).equalsIgnoreCase(PHOTOPERMISSION_MEMBER) && isChecked) {
                      chbValue.setChecked(false);
                      chbValue.setEnabled(true);
                      break;
                    } else if (field.get(NAME).equalsIgnoreCase(PHOTOPERMISSION_MEMBER)) {
                      chbValue.setChecked(false);
                      chbValue.setEnabled(false);
                      break;
                    }
                  }
                } else if (field.get(NAME).equalsIgnoreCase(VIDEOPERMISSION_ADMIN)) {
                  int size = lnr_form.getChildCount();
                  for (int i = 0; i < size; i++) {
                    View v = (LinearLayout) lnr_form.getChildAt(i);
                    HashMap<String, String> field = new HashMap<String, String>();
                    field.putAll((HashMap<String, String>) v.getTag());
                    IjoomerCheckBox chbValue =
                        (IjoomerCheckBox)
                            ((LinearLayout) v.findViewById(R.id.lnrCheckbox))
                                .findViewById(R.id.txtValue);
                    if (field.get(NAME).equalsIgnoreCase(VIDEOPERMISSION_MEMBER) && isChecked) {
                      chbValue.setChecked(false);
                      chbValue.setEnabled(true);
                      break;
                    } else if (field.get(NAME).equalsIgnoreCase(VIDEOPERMISSION_MEMBER)
                        && !isChecked) {
                      chbValue.setChecked(false);
                      chbValue.setEnabled(false);
                      break;
                    }
                  }
                } else if (field.get(NAME).equalsIgnoreCase(EVENTPERMISSION_ADMIN)) {
                  int size = lnr_form.getChildCount();
                  for (int i = 0; i < size; i++) {
                    View v = (LinearLayout) lnr_form.getChildAt(i);
                    HashMap<String, String> field = new HashMap<String, String>();
                    field.putAll((HashMap<String, String>) v.getTag());
                    IjoomerCheckBox chbValue =
                        (IjoomerCheckBox)
                            ((LinearLayout) v.findViewById(R.id.lnrCheckbox))
                                .findViewById(R.id.txtValue);
                    if (field.get(NAME).equalsIgnoreCase(EVENTPERMISSION_MEMBER) && isChecked) {
                      chbValue.setChecked(false);
                      chbValue.setEnabled(true);
                      break;
                    } else if (field.get(NAME).equalsIgnoreCase(EVENTPERMISSION_MEMBER)
                        && !isChecked) {
                      chbValue.setChecked(false);
                      chbValue.setEnabled(false);
                      break;
                    }
                  }
                }
              }
            });
      }

      try {
        if (field.get(REQUIRED).equalsIgnoreCase("1")) {
          ((IjoomerTextView) layout.findViewById(R.id.txtLable)).setText("* ");
        } else {
          ((IjoomerTextView) layout.findViewById(R.id.txtLable)).setText("   ");
        }
      } catch (Exception e) {
        ((IjoomerTextView) layout.findViewById(R.id.txtLable)).setText("   ");
      }

      fieldView.setTag(field);
      lnr_form.addView(fieldView, params);
    }
  }