I am not really sure how to word this question, so I did the best I could in that aspect. So I am having a problem with creating a DatePicker in my Activity. This is the code that is giving me an error:
EditEventActivity.java
DateDialogFragment frag = DateDialogFragment.newInstance(this, new
DateDialogFragmentListener() {
@Override
public void updateChangeDate(int year, int month, int day) {
// TODO Auto-generated method stub
}
}, sYear, sMonth, sDay);
The newInstance() method I have there is whats giving me the error. The error is this:
The method newInstance(Context, AddEventActivity.DateDialogFragmentListener, int, int, int) in the type DateDialogFragment is not applicable for the arguments (EditEventActivity, new EditEventActivity.DateDialogFragmentListener(){}, int, int, int)
Now the DateDialogFragment is located in its own file. I don’t think I need to post that. It is what it is. But my interface is in AddEventActivity.java. Now this is what I am confused about. My static method, newInstance() from DateDialogFragment takes DateDialogFragmentListenernot AddEventActivity.DateDialogFragmentListener. So I assume thats what the problem is. But then again, I am not sure, which is what I need help understanding. Thanks you in advance.
Actually. I also figue I might as well include the newInstance() method:
DateDialogFragment.java
public static DateDialogFragment newInstance(Context context, DateDialogFragmentListener
listener, int year, int month, int day) {
DateDialogFragment dialog = new DateDialogFragment();
mContext = context;
mListener = listener;
mYear = year;
mMonth = month;
mDay = day;
Bundle args = new Bundle();
args.putString("title", "Set Date");
dialog.setArguments(args);
return dialog;
}
You pass too many arguments to the
newInstance(...)method. Only passsYear,sMonthandsDayonce rather than twice.Edit
You’re having here two classes with the same simple name but they’re different classes and therefore different types. Just pass an instance of the right class.
.. or correct the signature of your
newInstance()method if you need to pass aEditEventActivity.DateDialogFragmentListener.