@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); // Set up Activity UI mRegisterActivity.setUpUi(RegisterBirthdayFragment.class); // Date text view mTvDate = (TextView) view.findViewById(R.id.login_tv_date); String currentDateString = DateUtils.date2StringForDisplay(DateUtils.stringApi2Date(mRegisterData.getBirthday())); if (currentDateString != "") { mTvDate.setText(currentDateString); } mTvDate.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { mTvDate.setClickable(false); FragmentManager manager = getFragmentManager(); DatePickerFragment dialog = DatePickerFragment.newInstance( DateUtils.stringUi2Date(mTvDate.getText().toString())); dialog.setTargetFragment(RegisterBirthdayFragment.this, REQUEST_DATE); dialog.show(manager, DIALOG_DATE); } }); }
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode != Activity.RESULT_OK) return; if (requestCode == REQUEST_DATE) { Date date = (Date) data.getSerializableExtra(DatePickerFragment.EXTRA_DATE); // Update for Upload mRegisterData.setBirthday(DateUtils.date2StringForUpload(date)); // Update for Display mTvDate.setText(DateUtils.date2StringForDisplay(date)); mTvDate.setClickable(true); } }