Why in my fragment getActivity() works but mContext.getApplicationContext() does not?
mDobPickerDialog = new DatePickerDialog(getActivity(), new OnDateSetListener() {
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
Calendar newDate = Calendar.getInstance();
newDate.set(year, monthOfYear, dayOfMonth);
mDobEditText.setText(mDateFormatter.format(newDate.getTime()));
}
},newCalendar.get(Calendar.YEAR), newCalendar.get(Calendar.MONTH), newCalendar.get(Calendar.DAY_OF_MONTH));
My mContext is declared and initialized as:
private Context mContext;
public DisplayProfileFragment(Context context) {
super();
mContext = context;
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…