編集日に選択した日付の値を設定しようとしています。私は、エラー、次の取得しています外部からedittext値を設定中にエラーが発生しました
のjava.lang.NullPointerException:nullのオブジェクト参照
public static class AddDataFragment extends BaseFragment implements {
@BindView(R.id.tvStartVisit)
public TextView tvStartVisit;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_add_visit, container, false);
ButterKnife.bind(this, view);
setData();
return view;
}
@OnClick(R.id.tvStartVisit)
public void onStartVisitDateClicked(){
DialogFragment newDialogFragment = new DatePickerFragment();
newDialogFragment.show(getActivity().getSupportFragmentManager(), "datePicker");
}
public static class DatePickerFragment extends DialogFragment
implements DatePickerDialog.OnDateSetListener {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current date as the default date in the picker
final Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int day = c.get(Calendar.DAY_OF_MONTH);
return new DatePickerDialog(getActivity(), this, year, month, day);
}
public void onDateSet(DatePicker view, int year, int month, int day) {
AddVisitFragment mAddVisitFragmentForDatePicker = new AddDataFragment();
mAddVisitFragmentForDatePicker.tvStartVisit.setText(year+"-"+month+"-"+day);
}
}
}
取得エラーを試します。 } –