Repository: rey5137/material

Issue #127: Getting Error in DateDialog in Activity not in Fragment
Created: 2015-05-23T05:47:46Z
My Code For it in Activity File is :
final DatePickerDialog datePickerDialog = new DatePickerDialog(
mContext, R.style.DatePicker);
datePickerDialog.positiveAction("OK").negativeAction("CANCEL");
datePickerDialog.positiveActionClickListener(new OnClickListener() {
@OverRide
public void onClick(View v) {
// TODO Auto-generated method stub
String date = datePickerDialog
.getFormattedDate(SimpleDateFormat
.getDateInstance());
Toast.makeText(mContext, "Date is " + date,
Toast.LENGTH_SHORT).show();
}
});
datePickerDialog.negativeActionClickListener(new OnClickListener() {
@OverRide
public void onClick(View v) {
// TODO Auto-generated method stub
String date = datePickerDialog
.getFormattedDate(SimpleDateFormat
.getDateInstance());
Toast.makeText(mContext, "Date is " + date,
Toast.LENGTH_SHORT).show();
}
});
datePickerDialog.setOwnerActivity(this);
datePickerDialog.show();

Duplicate issue #152: DatePickerDialog NullPointerException
Created: 2015-06-10T18:36:47Z
Hello! I have strange error while trying to create a simple DatePickerDialog:
Process: com.don11995.okstudy, PID: 17221
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
at android.view.GLES20Canvas.drawText(GLES20Canvas.java:920)
at com.rey.material.widget.DatePicker$MonthView.onDraw(DatePicker.java:563)
at android.view.View.draw(View.java:15239)
at android.view.View.updateDisplayListIfDirty(View.java:14175)
at android.view.View.getDisplayList(View.java:14197)
at android.view.View.draw(View.java:14967)
at android.view.ViewGroup.drawChild(ViewGroup.java:3406)
at android.widget.ListView.drawChild(ListView.java:3396)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3199)
at android.widget.AbsListView.dispatchDraw(AbsListView.java:2603)
at android.widget.ListView.dispatchDraw(ListView.java:3391)
at android.support.v7.internal.widget.ListViewCompat.dispatchDraw(ListViewCompat.java:107)
at android.view.View.draw(View.java:15242)
at android.widget.AbsListView.draw(AbsListView.java:4114)
at android.view.View.updateDisplayListIfDirty(View.java:14175)
at android.view.View.getDisplayList(View.java:14197)
at android.view.View.draw(View.java:14967)
at android.view.ViewGroup.drawChild(ViewGroup.java:3406)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3199)
at android.view.View.draw(View.java:15242)
at android.widget.FrameLayout.draw(FrameLayout.java:598)
at com.rey.material.app.DatePickerDialog$DatePickerLayout.draw(DatePickerDialog.java:609)
at android.view.View.updateDisplayListIfDirty(View.java:14175)
at android.view.View.getDisplayList(View.java:14197)
at android.view.View.draw(View.java:14967)
at android.view.ViewGroup.drawChild(ViewGroup.java:3406)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3199)
at android.view.View.draw(View.java:15242)
at android.widget.FrameLayout.draw(FrameLayout.java:598)
at com.rey.material.app.Dialog$DialogCardView.draw(Dialog.java:1285)
at android.view.View.updateDisplayListIfDirty(View.java:14175)
at android.view.View.getDisplayList(View.java:14197)
at android.view.View.draw(View.java:14967)
at android.view.ViewGroup.drawChild(ViewGroup.java:3406)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3199)
at android.view.View.updateDisplayListIfDirty(View.java:14170)
at android.view.View.getDisplayList(View.java:14197)
at android.view.View.draw(View.java:14967)
at android.view.ViewGroup.drawChild(ViewGroup.java:3406)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3199)
at android.view.View.updateDisplayListIfDirty(View.java:14170)
at android.view.View.getDisplayList(View.java:14197)
at android.view.View.draw(View.java:14967)
at android.view.ViewGroup.drawChild(ViewGroup.java:3406)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3199)
at android.view.View.updateDisplayListIfDirty(View.java:14170)
at android.view.View.getDisplayList(View.java:14197)
at android.view.View.draw(View.java:14967)
at android.view.ViewGroup.drawChild(ViewGroup.java:3406)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3199)
at android.view.View.draw(View.java:15242)
at android.widget.FrameLayout.draw(FrameLayout.java:598)
at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2650)
at android.view.View.updateDisplayListIfDirty(View.java:14175)
at android.view.View.getDisplayList(View.java:14197)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:273)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:279)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:318)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:2536)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2352)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1982)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1061)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5891)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
My code:
final DatePickerDialog builder  = new DatePickerDialog(getActivity());
builder.title("Title");
builder.positiveAction(R.string.ok);
builder.date(10,6,2015);
builder.show();
What am I doing wrong?

Closing comment (2015-06-11T02:35:46Z): A duplicate of #127 . I saw you already called date() method, but you should also call dateRange() method to set the range of selectable dates.