public TableLayout createTable() {
    int comboCounter = 0;
    TableLayout tl = new TableLayout(this);
    TableRow tr = new TableRow(this);
    CheckBox c;
    TextView text;
    for (int x = 0; x < KMapControl.getTopDisplay().length; x++) {
      text = new TextView(this);
      if (KMapControl.getKMapSize() == KMapController.VARIABLE_5) {
        if (x == 0) {
          fiveVarCounter += 1;
          text.setTextColor(Color.YELLOW);
          text.setText(fiveVarCounter + "  ");
        } else text.setText(KMapControl.getTopDisplay()[x]);
      } else {
        text.setText(KMapControl.getTopDisplay()[x]);
      }
      text.setPadding(PADDING, PADDING, PADDING, PADDING);
      tr.addView(text);
    }
    tl.addView(tr);

    for (int x = 0; x < KMapControl.getLeftDisplay().length; x++) {
      tr = new TableRow(this);
      text = new TextView(this);
      text.setText(KMapControl.getLeftDisplay()[x]);
      text.setPadding(PADDING, PADDING, PADDING, PADDING);
      tr.addView(text);

      for (int y = 1; y < KMapControl.getTopDisplay().length; y++) {
        c = new CheckBox(this);
        if (KMapControl.getKMapSize() == KMapController.VARIABLE_5 && fiveVarCounter == 1)
          c.setId(KMapControl.getTableLayout()[comboCounter] + 16);
        else c.setId(KMapControl.getTableLayout()[comboCounter]);
        c.setButtonDrawable(R.drawable.customcheck);
        c.setPadding(PADDING, PADDING, PADDING, PADDING);

        c.setOnCheckedChangeListener(
            new OnCheckedChangeListener() {

              @Override
              public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
                KMapControl.setVariableAtLocation(arg0.getId(), arg1);
                String s = "\nLast Selected:\n\nMinterm: " + arg0.getId() + "\n" + "State: ";
                if (arg1 == false) s += "0";
                else s += "1";
                s += "\nBinary: " + KMapControl.getBinarySpot(arg0.getId());
                s += "\nVariables: " + KMapControl.getStringVariableAtLocation(arg0.getId());
                display.setText(s);
              }
            });
        tr.addView(c);
        comboCounter += 1;
      }
      tl.addView(tr);
    }
    return tl;
  }
    public CheckBoxifiedTextView(
        final Context context, CheckBoxifiedText aCheckBoxifiedText, final int position) {
      super(context);
      this.setOrientation(HORIZONTAL);
      mCheckBoxText = aCheckBoxifiedText;
      mCheckBox = new CheckBox(context);
      mCheckBox.setPadding(0, 0, 20, 0); // 5px to the right
      mCheckBox.setChecked(aCheckBoxifiedText.getChecked());
      mCheckBox.setOnCheckedChangeListener(
          new OnCheckedChangeListener() {

            public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
              try {
                bArray[position] = mCheckBox.isChecked();
                // Toast.makeText(context, " position = " + Boolean.toString(bArray[0]) +
                // Boolean.toString(bArray[1]), Toast.LENGTH_LONG).show();
              } catch (Exception e) {
                // bArray[position] = mCheckBox.isChecked();
                // Toast.makeText(context, " position = " + Boolean.toString(bArray[0]) +
                // Boolean.toString(bArray[1]) + Boolean.toString(bArray[2]),
                // Toast.LENGTH_LONG).show();
                // Toast.makeText(context, " position = "+Integer.toString(position)+" rows =
                // "+Integer.toString(rows),Toast.LENGTH_SHORT).show();
              }
            }
          });

      /* bArray[position] = mCheckBox.isChecked();
      Toast.makeText(context, " position = " + Boolean.toString(bArray[0]) + Boolean.toString(bArray[1]) + Boolean.toString(bArray[2]), Toast.LENGTH_LONG).show();
      }
      });*/
      addView(
          mCheckBox,
          new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
      mText = new TextView(context);
      mText.setText(aCheckBoxifiedText.getText());
      addView(
          mText,
          new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    }
  public void getreportsent() {
    int i = 0;

    TableRow tr1 = new TableRow(this);
    tr1.setId(100 + i);
    tr1.layout(2, 0, 0, 0);

    // Create a TextView to house the name of the province
    final TextView label2 = new TextView(this);

    label2.setId(300 + i);
    label2.setText("      ");
    label2.setTextColor(Color.BLACK);
    label2.setPadding(20, 0, 0, 0);
    tr1.setPadding(0, 1, 0, 1);

    tr1.addView(label2);

    // Create a TextView to house the name of the province
    final TextView labeltitle2 = new TextView(this);

    labeltitle2.setId(300 + i);
    labeltitle2.setText("Subject");
    labeltitle2.setTextColor(Color.BLACK);
    labeltitle2.setPadding(20, 0, 0, 0);
    tr1.setPadding(0, 1, 0, 1);

    tr1.addView(labeltitle2);

    /*// Create a TextView to house the name of the province
    final TextView labelsend2 = new TextView(this);


    labelsend2.setId(500+i);
    labelsend2.setText("From");
    labelsend2.setTextColor(Color.BLACK);

    tr1.addView(labelsend2);*/

    // Create a TextView to house the value of the after-tax income
    final TextView labelrec2 = new TextView(this);

    labelrec2.setId(400 + i);
    labelrec2.setText("To");
    labelrec2.setTextColor(Color.BLACK);
    labelrec2.setPadding(20, 0, 0, 0);
    tr1.setPadding(0, 1, 0, 1);

    tr1.addView(labelrec2);

    // Create a TextView to house the value of the after-tax income
    final TextView labeldt2 = new TextView(this);

    labeldt2.setId(600 + i);
    labeldt2.setText("Date");
    labeldt2.setTextColor(Color.BLACK);
    labeldt2.setPadding(20, 0, 0, 0);
    tr1.setPadding(0, 1, 0, 1);

    tr1.addView(labeldt2);

    // Add the TableRow to the TableLayout
    tbl3.addView(
        tr1, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

    for (int i1 = 0; i1 < rec2.length; i1++) {

      try {
        TableRow tr = new TableRow(this);
        tr.setId(100 + i);
        tr.layout(2, 0, 0, 0);

        // Create a TextView to house the name of the province
        final CheckBox chk1 = new CheckBox(this);
        ;

        chk1.setId(200 + i);
        chk1.setText("");
        chk1.setPadding(20, 0, 0, 0);
        tr.setPadding(0, 1, 0, 1);

        tr.addView(chk1);

        // Create a TextView to house the name of the province
        final TextView labeltitle1 = new TextView(this);

        labeltitle1.setId(300 + i);
        labeltitle1.setText(title2[i1]);
        labeltitle1.setTextColor(Color.BLACK);
        labeltitle1.setPadding(20, 0, 0, 0);
        tr.setPadding(0, 1, 0, 1);

        tr.addView(labeltitle1);

        /*// Create a TextView to house the name of the province
        final TextView labelsend1 = new TextView(this);


        labelsend1.setId(500+i);
        labelsend1.setText(send2[i1]);
        labelsend1.setTextColor(Color.BLACK);

        tr.addView(labelsend1);*/

        // Create a TextView to house the value of the after-tax income
        final TextView labelrec1 = new TextView(this);

        labelrec1.setId(400 + i);
        labelrec1.setText("" + rec2[i1]);
        labelrec1.setTextColor(Color.BLACK);
        labelrec1.setPadding(20, 0, 0, 0);
        tr.setPadding(0, 1, 0, 1);

        tr.addView(labelrec1);

        int date1 = Integer.parseInt(dt2[i1]);

        Date date = new Date(date1 * 1000L);

        SimpleDateFormat postFormater = new SimpleDateFormat("dd-MM-yyyy");

        String newDateStr = postFormater.format(date);

        // Create a TextView to house the value of the after-tax income
        final TextView labeldt1 = new TextView(this);

        labeldt1.setId(600 + i);
        labeldt1.setText("" + newDateStr);
        labeldt1.setTextColor(Color.BLACK);
        labeldt1.setPadding(20, 0, 0, 0);
        tr.setPadding(0, 1, 0, 1);

        tr.addView(labeldt1);

        final TextView labelbody1 = new TextView(this);

        labelbody1.setId(700 + i);
        labelbody1.setText("" + body2[i1]);
        labelbody1.setTextColor(Color.BLACK);
        labelbody1.setVisibility(View.GONE);

        labelbody1.setPadding(20, 0, 0, 0);
        tr.setPadding(0, 1, 0, 1);

        tr.addView(labelbody1);

        // Add the TableRow to the TableLayout
        tbl3.addView(
            tr, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
        i++;

        labeltitle1.setOnClickListener(
            new TextView.OnClickListener() {

              public void onClick(View v) {

                myDialog1 = new Dialog(mailbox.this);
                myDialog1.setContentView(R.layout.showmail);
                myDialog1.setTitle("Sent Mails");
                myDialog1.setCancelable(true);

                TextView from = (TextView) myDialog1.findViewById(R.id.txtfrom);
                TextView date = (TextView) myDialog1.findViewById(R.id.txtdate);
                TextView to = (TextView) myDialog1.findViewById(R.id.txtto);
                TextView title = (TextView) myDialog1.findViewById(R.id.txttitle);
                EditText body = (EditText) myDialog1.findViewById(R.id.editto);
                Button button = (Button) myDialog1.findViewById(R.id.btnback);

                String rec1 = labelrec1.getText().toString();

                String date1 = labeldt1.getText().toString();

                // String send1=labelsend1.getText().toString();

                String title1 = labeltitle1.getText().toString();

                String body1 = labelbody1.getText().toString();
                button.setText("Back To Sent mails");

                // from.setText(send1);
                date.setText(date1);
                to.setText(rec1);
                title.setText(title1);
                body.setText(body1);

                button.setOnClickListener(
                    new OnClickListener() {
                      public void onClick(View v) {
                        myDialog1.dismiss();
                      }
                    });

                myDialog1.show();
              }
            });
      } catch (Exception e) {
        tv.setText(e.getMessage());
      }
    }
  }
Пример #4
0
  private LinearLayout createProductInfo(com.app.commons.JSONObject jo) {
    JSONArray ja = jo.getJSONArray("settleGoods");
    if (ja == null || ja.length() == 0) {
      return null;
    }
    final String productSku = jo.getString("productSku");
    LinearLayout info = new LinearLayout(CartActivtiy.this);
    int cart_height = Math.round(getResources().getDimension(R.dimen.cart_height));
    info.setLayoutParams(
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    info.setMinimumHeight(cart_height);
    info.setOrientation(LinearLayout.HORIZONTAL);
    info.setGravity(Gravity.CENTER_VERTICAL);
    info.setBackgroundResource(R.drawable.border2);
    info.setPadding(10, 0, 10, 0);
    final CheckBox rb = new CheckBox(CartActivtiy.this);
    rb.setPadding(0, 0, 10, 0);
    rb.setButtonDrawable(R.drawable.checkbox);
    if (jo.getBoolean("checked")) {
      rb.setChecked(true);
      settleNum = settleNum + 1;
    } else {
      rb.setChecked(false);
    }
    rb.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            Map<String, Object> param = new HashMap<>();
            param.put("ids", productSku);
            param.put("checkeds", rb.isChecked() ? "Y" : "N");
            Utils.asyncHttpRequestPost(
                Constants.URL_CART_CHANGESTATUS,
                param,
                new JsonHttpResponseHandler() {
                  @Override
                  public void onSuccess(int statusCode, Header[] headers, JSONObject res) {
                    com.app.commons.JSONObject jo = new com.app.commons.JSONObject(res);
                    if (statusCode == 200) {
                      if (jo.getBoolean("success")) {
                        flushCartInfo();
                      } else {
                        Toast.makeText(
                                CartActivtiy.this, jo.getString("errMsg"), Toast.LENGTH_SHORT)
                            .show();
                        flushCartInfo();
                      }
                    } else {
                      Toast.makeText(CartActivtiy.this, statusCode, Toast.LENGTH_SHORT).show();
                    }
                  }
                });
          }
        });
    info.addView(rb);
    LinearLayout center = new LinearLayout(CartActivtiy.this);
    LinearLayout.LayoutParams centerLP =
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    centerLP.weight = 1;
    center.setOrientation(LinearLayout.VERTICAL);
    center.setLayoutParams(centerLP);
    center.setPadding(10, 0, 0, 0);
    int wh2 = Math.round(getResources().getDimension(R.dimen.btn_cart_height));
    if (ja != null && ja.length() > 0) {
      ImageView iv = new ImageView(CartActivtiy.this);
      int wh = Math.round(getResources().getDimension(R.dimen.cart_img_wh));
      iv.setLayoutParams(new ViewGroup.LayoutParams(wh, wh));
      iv.setImageResource(R.drawable.loading);
      Utils.asyncLoadInternetImageView(
          iv, Constants.URL_IMAGE + "/200X200" + ja.getJSONObject(0).getString("photoUrl"));
      info.addView(iv);
      TextView tv = new TextView(CartActivtiy.this);
      if (ja.length() == 1) {
        tv.setText(ja.getJSONObject(0).getString("goodsName"));
      } else {
        tv.setText(getResources().getString(R.string.goods_set));
      }
      center.addView(tv);
      LinearLayout bottom = new LinearLayout(CartActivtiy.this);
      bottom.setLayoutParams(
          new ViewGroup.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
      bottom.setOrientation(LinearLayout.HORIZONTAL);
      bottom.setPadding(0, 15, 0, 0);
      LinearLayout.LayoutParams wrap = new LinearLayout.LayoutParams(wh2, wh2);
      wrap.setMargins(5, 0, 5, 0);
      final EditText et = new EditText(CartActivtiy.this);
      et.setBackgroundResource(R.drawable.wrapcontent);
      et.setText(jo.getString("number"));
      et.setSingleLine(true);
      et.setKeyListener(new DigitsKeyListener(false, false));
      et.setLayoutParams(wrap);
      et.setGravity(Gravity.RIGHT);
      et.setPadding(5, 2, 5, 2);
      et.setFocusable(true);
      et.addTextChangedListener(
          new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {}

            @Override
            public void afterTextChanged(Editable editable) {
              if (editable.length() == 0) {
                editable.append(String.valueOf(def_num));
              } else if (Integer.parseInt(editable.toString()) <= 0) {
                editable.replace(0, 1, String.valueOf(def_num));
              } else if (editable.length() > 2) {
                editable.replace(0, editable.length(), String.valueOf(def_maxnum));
              }
              Map<String, Object> param = new HashMap<>();
              param.put("id", productSku);
              param.put("count", editable.toString());
              Utils.asyncHttpRequestPost(
                  Constants.URL_CART_CHANGENUMBER,
                  param,
                  new JsonHttpResponseHandler() {
                    @Override
                    public void onSuccess(int statusCode, Header[] headers, JSONObject res) {
                      com.app.commons.JSONObject jo = new com.app.commons.JSONObject(res);
                      if (statusCode == 200) {
                        if (jo.getBoolean("success")) {
                          flushCartInfo();
                        } else {
                          Toast.makeText(
                                  CartActivtiy.this, jo.getString("errMsg"), Toast.LENGTH_SHORT)
                              .show();
                          flushCartInfo();
                        }
                      } else {
                        Toast.makeText(CartActivtiy.this, statusCode, Toast.LENGTH_SHORT).show();
                      }
                    }
                  });
            }
          });
      ImageView sub = new ImageView(CartActivtiy.this);
      sub.setScaleType(ImageView.ScaleType.FIT_CENTER);
      sub.setLayoutParams(wrap);
      sub.setImageResource(R.drawable.cart_sub);
      sub.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              int num = Integer.parseInt(et.getText().toString());
              if (num > 1) {
                et.setText(String.valueOf((num - 1)));
              }
            }
          });
      ImageView add = new ImageView(CartActivtiy.this);
      add.setLayoutParams(wrap);
      add.setScaleType(ImageView.ScaleType.FIT_CENTER);
      add.setImageResource(R.drawable.cart_add);
      add.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              Integer num = Integer.parseInt(et.getText().toString());
              et.setText(String.valueOf(num + 1));
            }
          });
      bottom.addView(sub);
      bottom.addView(et);
      bottom.addView(add);
      if (jo.getString("remark") != null) {
        TextView remark = new TextView(CartActivtiy.this);
        remark.setText(jo.getString("remark"));
        remark.setTextColor(getResources().getColor(R.color.red));
        bottom.addView(remark);
      }
      center.addView(bottom);
    }
    LinearLayout right = new LinearLayout(CartActivtiy.this);
    right.setOrientation(LinearLayout.VERTICAL);
    right.setGravity(Gravity.CENTER);
    right.setPadding(0, 0, 0, 5);
    TextView tv2 = new TextView(CartActivtiy.this);
    tv2.setLayoutParams(
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    tv2.setGravity(Gravity.CENTER);
    tv2.setText("¥" + jo.getString("amount"));
    tv2.setTextColor(getResources().getColor(R.color.red));
    right.addView(tv2);
    ImageButton ib = new ImageButton(CartActivtiy.this);
    int cdelw = Math.round(getResources().getDimension(R.dimen.cart_delete_width));
    int cdelh = Math.round(getResources().getDimension(R.dimen.cart_delete_height));
    ib.setLayoutParams(new ViewGroup.LayoutParams(cdelw, cdelh));
    ib.setScaleType(ImageView.ScaleType.FIT_CENTER);
    ib.setBackgroundResource(R.drawable.border3);
    ib.setImageResource(R.drawable.cart_delete);
    ib.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            Map<String, Object> param = new HashMap<String, Object>();
            param.put("ids", productSku);
            Utils.asyncHttpRequestPost(
                Constants.URL_CART_DELETEPRODUCTS,
                param,
                new JsonHttpResponseHandler() {
                  @Override
                  public void onSuccess(int statusCode, Header[] headers, JSONObject res) {
                    com.app.commons.JSONObject jo = new com.app.commons.JSONObject(res);
                    if (statusCode == 200) {
                      if (jo.getBoolean("success")) {
                        flushCartInfo();
                      } else {
                        Toast.makeText(
                                CartActivtiy.this, jo.getString("errMsg"), Toast.LENGTH_SHORT)
                            .show();
                        flushCartInfo();
                      }
                    } else {
                      Toast.makeText(CartActivtiy.this, statusCode, Toast.LENGTH_SHORT).show();
                    }
                  }
                });
          }
        });
    right.addView(ib);
    info.addView(center);
    info.addView(right);
    return info;
  }
Пример #5
0
  @SuppressWarnings("unchecked")
  public SelectMultiWidget(Context context, FormEntryPrompt prompt) {
    super(context, prompt);
    mPrompt = prompt;
    mCheckboxes = new Vector<CheckBox>();
    mItems = prompt.getSelectChoices();

    setOrientation(LinearLayout.VERTICAL);

    Vector<Selection> ve = new Vector<Selection>();
    if (prompt.getAnswerValue() != null) {
      ve = (Vector<Selection>) getCurrentAnswer().getValue();
    }

    // Is this safe enough from collisions?
    buttonIdBase = Math.abs(prompt.getIndex().toString().hashCode());

    if (prompt.getSelectChoices() != null) {
      for (int i = 0; i < mItems.size(); i++) {
        // no checkbox group so id by answer + offset
        final CheckBox c = new CheckBox(getContext());

        c.setId(buttonIdBase + i);
        c.setText(stylize(prompt.getSelectChoiceText(mItems.get(i))));
        c.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize);
        c.setFocusable(!prompt.isReadOnly());
        c.setEnabled(!prompt.isReadOnly());

        int padding = (int) Math.floor(context.getResources().getDimension(R.dimen.select_padding));

        c.setPadding(c.getPaddingLeft(), 0, padding, 0);
        for (int vi = 0; vi < ve.size(); vi++) {
          // match based on value, not key
          if (mItems.get(i).getValue().equals(ve.elementAt(vi).getValue())) {
            c.setChecked(true);
            break;
          }
        }

        // Note: This gets fired during setup as well, so this listener should only
        // be added after everything about the checkbox is set up

        // when clicked, check for readonly before toggling
        c.setOnCheckedChangeListener(
            new CompoundButton.OnCheckedChangeListener() {
              /*
               * (non-Javadoc)
               * @see android.widget.CompoundButton.OnCheckedChangeListener#onCheckedChanged(android.widget.CompoundButton, boolean)
               */
              @Override
              public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (!mCheckboxInit && mPrompt.isReadOnly()) {
                  if (buttonView.isChecked()) {
                    buttonView.setChecked(false);
                  } else {
                    buttonView.setChecked(true);
                  }
                }
                widgetEntryChanged();
              }
            });

        mCheckboxes.add(c);

        String audioURI = null;
        audioURI =
            prompt.getSpecialFormSelectChoiceText(mItems.get(i), FormEntryCaption.TEXT_FORM_AUDIO);

        String imageURI = null;
        imageURI =
            prompt.getSpecialFormSelectChoiceText(mItems.get(i), FormEntryCaption.TEXT_FORM_IMAGE);

        String videoURI = null;
        videoURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), "video");

        String bigImageURI = null;
        bigImageURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), "big-image");

        MediaLayout mediaLayout = new MediaLayout(getContext());
        mediaLayout.setAVT(c, audioURI, imageURI, videoURI, bigImageURI);
        addView(mediaLayout);

        mediaLayout.setPadding(0, padding, 0, padding);

        mediaLayout.setOnClickListener(
            new OnClickListener() {

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

        // Last, add the dividing line between elements (except for the last element)
        ImageView divider = new ImageView(getContext());
        divider.setBackgroundResource(android.R.drawable.divider_horizontal_bright);
        if (i != mItems.size() - 1) {
          addView(divider);
        }
      }
    }

    mCheckboxInit = false;
  }
Пример #6
0
  private void dibujarDias() {
    for (int i = 0; i < mDias.size(); i++) {
      final List<String> needPhotos = new ArrayList<>();

      View vDia = LayoutInflater.from(this).inflate(R.layout.proyectos_detalle, null, false);

      TextView dia_p_programado = (TextView) vDia.findViewById(R.id.programado);
      final TextView dia_p_real = (TextView) vDia.findViewById(R.id.real);
      TextView dia_n = (TextView) vDia.findViewById(R.id.dia);
      final LinearLayout dia_contenido = (LinearLayout) vDia.findViewById(R.id.content);
      final LinearLayout dia_actividades = (LinearLayout) vDia.findViewById(R.id.activityList);
      final EditText p_real = (EditText) vDia.findViewById(R.id.avance);
      final EditText p_fecha = (EditText) vDia.findViewById(R.id.fecha);
      EditText p_observacion = (EditText) vDia.findViewById(R.id.observacion);
      final ImageButton expand = (ImageButton) vDia.findViewById(R.id.expand);
      ImageButton dia_foto = (ImageButton) vDia.findViewById(R.id.foto);

      /*p_fecha.setOnFocusChangeListener(new View.OnFocusChangeListener() {
          @Override
          public void onFocusChange(View view, boolean b) {
              if (b) {
                  p_fecha.setText("");
              }
          }
      });*/
      dia_foto.setVisibility(View.GONE);

      expand.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              if (dia_contenido.getVisibility() == View.GONE) {
                dia_contenido.setVisibility(View.VISIBLE);
                expand.setImageResource(R.drawable.ic_action_close);
              } else {
                dia_contenido.setVisibility(View.GONE);
                expand.setImageResource(R.drawable.ic_action_open);
              }
            }
          });

      final Dia dia = mDias.get(i);
      final ArrayList<Actividad> actividadArrayList = dia.getActividades();
      dia.setAdvanceToday("0");

      p_fecha.setText(dia.getDate());

      /*p_fecha.setOnFocusChangeListener(new View.OnFocusChangeListener() {
          @Override
          public void onFocusChange(View view, boolean b) {
              if (!b) {
                  if (!Funciones.validateDate(p_fecha.getText().toString())) {
                      AlertDialog.Builder b1 = new AlertDialog.Builder(mContext);
                      b1.setIcon(android.R.drawable.ic_dialog_alert);
                      b1.setMessage("Formato de fecha Incorrecto.\nDebe ser AAAA-MM-DD");
                      b1.setTitle("Dia " + dia.getDayNumber());
                      b1.setNeutralButton("OK", new DialogInterface.OnClickListener() {
                          @Override
                          public void onClick(DialogInterface dialogInterface, int i) {
                              dialogInterface.dismiss();
                          }
                      });
                      b1.show();
                      error = true;
                  } else {
                      error = false;
                      try {
                          DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
                          Date hoy = new Date();
                          Date fecha_envia = formatter.parse(p_fecha.getText().toString());

                          Log.d("FECHAS", hoy + "  " + fecha_envia);
                          if (formatter.format(fecha_envia).compareTo(formatter.format(hoy)) < 0) {
                              AlertDialog.Builder b1 = new AlertDialog.Builder(mContext);
                              b1.setIcon(android.R.drawable.ic_dialog_alert);
                              b1.setMessage("No puede ingresar una fecha anterior al día de hoy.");
                              b1.setTitle("Dia " + dia.getDayNumber());
                              b1.setNeutralButton("OK", new DialogInterface.OnClickListener() {
                                  @Override
                                  public void onClick(DialogInterface dialogInterface, int i) {
                                      dialogInterface.dismiss();
                                  }
                              });
                              b1.show();
                              error = true;
                          }
                      } catch (Exception e) {
                          e.printStackTrace();
                          error = true;
                      }

                  }
              }
          }
      });*/

      p_observacion.setText(dia.getDescriptionDay());
      dia_p_programado.setText(dia.getProgrammedAdvance());
      dia_p_real.setText(dia.getRealAdvance());
      dia_n.setText("DIA " + dia.getDayNumber());

      dia.setFecha(p_fecha);
      dia.setlContenido(dia_contenido);

      ArrayList<CheckBox> checkBoxes = new ArrayList<>();
      for (int j = 0; j < actividadArrayList.size(); j++) {
        final Actividad a = actividadArrayList.get(j);

        /** SI una actividad requiere foto se activara el boton * */
        if (a.isFoto()) dia_foto.setVisibility(View.VISIBLE);
        needPhotos.add(dia.getDayNumber() + ";" + a.getNameActivity());

        CheckBox c = new CheckBox(mContext);
        c.setLayoutParams(
            new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        c.setText(a.getNameActivity());
        c.setPadding(0, 0, 0, 24);

        if (a.isSelected()) {
          c.setEnabled(false);
          c.setChecked(true);
        }

        c.setOnCheckedChangeListener(
            new CompoundButton.OnCheckedChangeListener() {
              @Override
              public void onCheckedChanged(CompoundButton compoundButton, boolean b) {

                Log.i("CHECKBOX LISTENER", "****");
                float advance;
                if (dia.getAdvanceToday() == null) {
                  advance = 0;
                } else advance = Float.parseFloat(dia.getAdvanceToday());
                Log.i("CHECKBOX LISTENER", "advance: " + advance);
                try {
                  if (b) {
                    advance += a.getAdvance();
                    avance_real_total += a.getAdvance();
                    dia.setModify(true);

                    for (int k = dia.getDayNumber() - 1; k < mAvances.size(); k++) {
                      float actual = Float.parseFloat(mAvances.get(k).getText().toString());
                      mAvances
                          .get(k)
                          .setText(
                              String.format(Locale.US, FLOAT_FORMAT, (actual + a.getAdvance())));
                    }

                  } else {
                    advance -= a.getAdvance();
                    avance_real_total -= a.getAdvance();
                    if (advance < 0) advance *= -1;

                    for (int k = dia.getDayNumber() - 1; k < mAvances.size(); k++) {
                      float actual = Float.parseFloat(mAvances.get(k).getText().toString());
                      mAvances
                          .get(k)
                          .setText(
                              String.format(Locale.US, FLOAT_FORMAT, (actual - a.getAdvance())));
                    }
                  }

                  Log.i("CHECKBOX LISTENER", "to: " + advance);
                  dia.setAdvanceToday(String.format(Locale.US, FLOAT_FORMAT, advance));
                  p_real.setText(String.format(Locale.US, FLOAT_FORMAT, advance));
                  updateProgresoTotal();
                } catch (Exception e) {
                  Toast.makeText(
                          mContext,
                          e.getMessage() + "\n" + e.getCause() + "\n" + e.getLocalizedMessage(),
                          Toast.LENGTH_LONG)
                      .show();
                }
              }
            });
        checkBoxes.add(c);
        dia_actividades.addView(c);
      }

      dia_foto.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              DateFormat timestamp_name = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
              imgActual = new ImagenDia(mProyecto.getId(), dia.getDayNumber(), null, new Date());
              imgActual.setFilename(
                  imgActual.getIdproject()
                      + "_"
                      + imgActual.getIdday()
                      + "_"
                      + timestamp_name.format(imgActual.getTimestamp())
                      + ".png");
              tomarFotografia();
            }
          });

      mAvances.add(dia_p_real);
      dia.setFecha(p_fecha);
      dia.setObservacion(p_observacion);
      dia.setAvance(p_real);
      dia.setCheckBoxes(checkBoxes);
      listadoDias.addView(vDia);
    }
  }