Skip to content Skip to sidebar Skip to footer

Using Datepicker On Custom Dialog

Well ,thats my code.I want to take values from a DatePicker from a custom Dialog. When i try to initialize dp (DatePicker) i got a nullPointerException error and i cant take the va

Solution 1:

For starters, you don't need this line in your onCreate():

dp=(DatePicker)findViewById(R.id.notdate);

Since your DatePicker View is not on the screen yet this will return null to you inside your onCreate();

Inside the onCreateDialog I think you just need to make it:

dp = (DatePicker)dialog.findViewById(R.id.notdate);

That should fix your null pointer.

Post a Comment for "Using Datepicker On Custom Dialog"