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 #149: DatePicker$MonthView
Created: 2015-06-06T23:00:38Z
The following code throws exception. Please help.
The exception is caused by
        datePickerDialog.show();
method. TimePickerDialog is working good.
Please solve this issue, I am in deadline.
Here is the full code of a method.
    public void time(View view) {
        final Button button = (Button)view;
        final Date date;
        final long[] time = {0};
        final TimePickerDialog timePickerDialog = new TimePickerDialog(this);
        final DatePickerDialog datePickerDialog = new DatePickerDialog(this);
        final DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy hh:mm a");

        datePickerDialog.positiveAction("SET");
        datePickerDialog.positiveActionClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                time[0] = datePickerDialog.getDate();
                datePickerDialog.dismiss();
                timePickerDialog.show();
            }
        });

        timePickerDialog.positiveAction("SET");
        timePickerDialog.positiveActionClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                time[0] = time[0]+100*60*timePickerDialog.getMinute()*timePickerDialog.getHour();
                button.setText(dateFormat.format(time[0]));
                timePickerDialog.dismiss();
            }
        });

        datePickerDialog.show();
    }
Exception Thrown:
06-07 04:25:07.121  19857-19857/in.ezyride.ezyride E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: in.ezyride.ezyride, PID: 19857
    java.lang.NullPointerException
            at android.view.GLES20Canvas.drawText(GLES20Canvas.java:1293)
            at com.rey.material.widget.DatePicker$MonthView.onDraw(DatePicker.java:563)
            at android.view.View.draw(View.java:14740)
            at android.view.View.getDisplayList(View.java:13636)
            at android.view.View.getDisplayList(View.java:13678)
            at android.view.View.draw(View.java:14457)
            at android.view.ViewGroup.drawChild(ViewGroup.java:3117)
            at android.widget.ListView.drawChild(ListView.java:3363)
            at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2954)
            at android.widget.AbsListView.dispatchDraw(AbsListView.java:2507)
            at android.widget.ListView.dispatchDraw(ListView.java:3358)
            at android.support.v7.internal.widget.ListViewCompat.dispatchDraw(ListViewCompat.java:107)
            at android.view.View.draw(View.java:14743)
            at android.widget.AbsListView.draw(AbsListView.java:4064)
            at android.view.View.getDisplayList(View.java:13636)
            at android.view.View.getDisplayList(View.java:13678)
            at android.view.View.draw(View.java:14457)
            at android.view.ViewGroup.drawChild(ViewGroup.java:3117)
            at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2954)
            at android.view.View.draw(View.java:14743)
            at android.widget.FrameLayout.draw(FrameLayout.java:472)
            at com.rey.material.app.DatePickerDialog$DatePickerLayout.draw(DatePickerDialog.java:609)
            at android.view.View.getDisplayList(View.java:13636)
            at android.view.View.getDisplayList(View.java:13678)
            at android.view.View.draw(View.java:14457)
            at android.view.ViewGroup.drawChild(ViewGroup.java:3117)
            at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2954)
            at android.view.View.draw(View.java:14743)
            at android.widget.FrameLayout.draw(FrameLayout.java:472)
            at com.rey.material.app.Dialog$DialogCardView.draw(Dialog.java:1285)
            at android.view.View.getDisplayList(View.java:13636)
            at android.view.View.getDisplayList(View.java:13678)
            at android.view.View.draw(View.java:14457)
            at android.view.ViewGroup.drawChild(ViewGroup.java:3117)
            at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2954)
            at android.view.View.getDisplayList(View.java:13631)
            at android.view.View.getDisplayList(View.java:13678)
            at android.view.View.draw(View.java:14457)
            at android.view.ViewGroup.drawChild(ViewGroup.java:3117)
            at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2954)
            at android.view.View.draw(View.java:14743)
            at android.widget.FrameLayout.draw(FrameLayout.java:472)
            at android.view.View.getDisplayList(View.java:13636)
            at android.view.View.getDisplayList(View.java:13678)
            at android.view.View.draw(View.java:14457)
            at android.view.ViewGroup.drawChild(ViewGroup.java:3117)
            at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2954)
            at android.view.View.getDisplayList(View.java:13631)
            at android.view.View.getDisplayList(View.java:13678)
            at android.view.View.draw(View.java:14457)
            at android.view.ViewGroup.drawChild(ViewGroup.java:3117)
            at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2954)
            at android.view.View.draw(View.java:14743)
            at android.widget.FrameLayout.draw(FrameLayout.java:472)
            at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2329)
            at android.view.View.getDisplayList(View.java:13636)
            at android.view.View.getDisplayList(View.java:13678)
            at android.view.HardwareRenderer$GlRenderer.buildDisplayList(HardwareRenderer.java:1570)
            at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1449)
            at android.view.ViewRootImpl.draw(ViewRootImpl.java:2401)
            at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2273)
            at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1903)
            at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1020)
            at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5762)
            at android.view.Choreographer$CallbackRecord.run(Choreographer.java:771)
            at android.view.Choreographer.doCallbacks(Choreographer.java:574)
            at android.view.Choreographer.doFrame(Choreographer.java:544)
            at android.view.Choreographe

Closing comment (2015-06-10T07:16:38Z): A duplicate of #127 . You should call date() and dateRange() methods of DatePickerDialog class.