コード例 #1
0
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle saveInstanceState) {
    View view = inflater.inflate(R.layout.ishas_fragment, parent, false);
    mEditText = (EditText) view.findViewById(R.id.ishas_fragment_edit);
    mButton = (Button) view.findViewById(R.id.ishas_fragment_button);
    textView = (TextView) view.findViewById(R.id.ishas_fragment_title);
    addnewHas = (Button) view.findViewById(R.id.ishas_fragment_add);
    addnewHas.setVisibility(View.VISIBLE);
    textView.setText(getActivity().getResources().getText(R.string.ishas));

    if (mDetailInformation.getHasDate() == null) {
      mButton.setText(TimeTool.DateToYYMMDD(new Date()));
    } else {
      mButton.setText(TimeTool.DateToYYMMDD(mDetailInformation.getHasDate()));
    }
    mButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            if (mDetailInformation.getHasDate() == null) {
              mDateDialogFragment = DateDialogFragment.getInstance(new Date());
            } else {
              mDateDialogFragment = DateDialogFragment.getInstance(mDetailInformation.getHasDate());
            }
            mDateDialogFragment.show(
                getActivity().getSupportFragmentManager(), DateDialogFragment.TAG);
            mDateDialogFragment.setTargetFragment(IsHasFragment.this, QUEST_DATA);
          }
        });

    mEditText.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.toString().equals("")) {
              mDetailInformation.setNumber(0);
            } else {
              mDetailInformation.setNumber(Integer.valueOf(editable.toString()));
            }
          }
        });

    addnewHas.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            detailInformation.getmDetailLPinformation().add(mDetailInformation);
            detailInformation.setIsHave(true);
            detailInformation.setMating(false);
            detailInformation.setPregnant(false);
          }
        });
    return view;
  }
コード例 #2
0
 @Override
 public void onActivityResult(int requestCode, int resultCode, Intent data) {
   if (resultCode != AppCompatActivity.RESULT_OK) {
     return;
   }
   if (requestCode == QUEST_DATA) {
     Date date = (Date) data.getSerializableExtra(DateDialogFragment.RETURN_INFORMATION);
     mDetailInformation.setHasDate(date);
     mButton.setText(TimeTool.DateToYYMMDD(mDetailInformation.getHasDate()));
   }
 }