コード例 #1
0
    private void setUpReminderTextFields() {
      // Set the default values for text fields
      editTitle = (EditText) v.findViewById(R.id.editTextTitle);
      editDueDate = (EditText) v.findViewById(R.id.editTextDueDate);
      editAmount = (EditText) v.findViewById(R.id.editTextAmount);
      editPaid = (EditText) v.findViewById(R.id.editTextPaid);

      editTitle.setText(reminder.getTitle());
      if (reminder.getDueDate() == null || reminder.getDueDate() == "")
        editDueDate.setText(defaultCurDate);
      else editDueDate.setText(reminder.getDueDate());
      editAmount.setText("" + String.format("%.2f", reminder.getBilledAmount()));
      editPaid.setText("" + String.format("%.2f", reminder.getPaidAmount()));
    }
コード例 #2
0
    private void addItem(final Reminder reminder) {
      final int reminderID = reminder.getId();
      String title = reminder.getTitle();
      String billedAmt = String.valueOf(reminder.getBilledAmount());
      String paidAmt = String.valueOf(reminder.getPaidAmount());
      String unpaidAmt = String.valueOf(Double.valueOf(billedAmt) - Double.valueOf(paidAmt));
      String dueDate = reminder.getDueDate();

      int days = Integer.parseInt(TimeUtils.getDateDiffStr(dueDate));

      // Instantiate a new "row" view.
      final ViewGroup newView =
          (ViewGroup)
              LayoutInflater.from(context)
                  .inflate(R.layout.layoutchange_list_item, mContainerView, false);

      newView.setOnLongClickListener(
          new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
              flipCard(reminder);
              return true;
            }
          });

      // Set the text in the new row to a random country.
      TextView reminderTitleView = (TextView) newView.findViewById(R.id.reminderTitle);
      reminderTitleView.setText(title);
      reminderTitleView.setOnLongClickListener(
          new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
              flipCard(reminder);
              return true;
            }
          });

      TextView reminderAmtView = (TextView) newView.findViewById(R.id.reminderAmtInfo);
      reminderAmtView.setText("$" + unpaidAmt + " out of " + billedAmt + " unpaid");
      reminderAmtView.setOnLongClickListener(
          new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
              flipCard(reminder);
              return true;
            }
          });

      TextView reminderDateView = (TextView) newView.findViewById(R.id.reminderDateInfo);
      if (days <= 1) reminderDateView.setText(days + " day unitl " + dueDate);
      else reminderDateView.setText(days + " days unitl " + dueDate);
      reminderDateView.setOnLongClickListener(
          new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
              flipCard(reminder);
              return true;
            }
          });

      // Set a click listener for the "X" button in the row that will remove the row.
      newView
          .findViewById(R.id.delete_button)
          .setOnClickListener(
              new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                  AlarmManagerBroadcastReceiver alarm = new AlarmManagerBroadcastReceiver();
                  alarm.cancelAlarm(context, reminderID);

                  dbManager.deleteReminder(reminderID);

                  // Remove the row from its parent (the container view).
                  // Because mContainerView has android:animateLayoutChanges set to true,
                  // this removal is automatically animated.
                  mContainerView.removeView(newView);

                  // If there are no rows remaining, show the empty view.
                  if (mContainerView.getChildCount() == 0) emptyText.setVisibility(View.VISIBLE);
                }
              });

      // Because mContainerView has android:animateLayoutChanges set to true,
      // adding this view is automatically animated.
      mContainerView.addView(newView, 0);
    }