You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My MainActivity class extends a BaseFragmentActivity (Custom) which extends FragmentActivity and I can't change it as changing it disturbs my App's functionality. MainActivity neither includes a ToolBar nor it's hidden in styles.xml for the Custom MainActivity Theme. Now I implemented the library as implementation 'com.wdullaer:materialdatetimepicker:4.2.3' and used the sample code to show DatePickerDialog as below but I am getting an exception which occurs as soon as I click on imageSearch ImageView. Please help me to resolve this issue. Also, I am implementing it in Tablet UI.
imageSearch.setOnClickListener(v -> {
Calendar now = Calendar.getInstance();
com.wdullaer.materialdatetimepicker.date.DatePickerDialog dpd = com.wdullaer.materialdatetimepicker.date.DatePickerDialog.newInstance(
onDateSetListener,
now.get(Calendar.YEAR), // Initial year selection
now.get(Calendar.MONTH), // Initial month selection
now.get(Calendar.DAY_OF_MONTH) // Inital day selection
);
// If you're calling this from an AppCompatActivity
dpd.show(getSupportFragmentManager(), "Datepickerdialog");
});
private com.wdullaer.materialdatetimepicker.date.DatePickerDialog.OnDateSetListener onDateSetListener = (view, year, monthOfYear, dayOfMonth) -> {
String date = "You picked the following date: " + dayOfMonth + "/" + (++monthOfYear) + "/" + year;
Log.e("DatePickerDialog", "onDateSet: selectedDate=> " + date);
};
Crash:
FATAL EXCEPTION: main
Process: com.noteactivethreebeta, PID: 12716
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference
at com.android.internal.app.WindowDecorActionBar.getDecorToolbar(WindowDecorActionBar.java:247)
at com.android.internal.app.WindowDecorActionBar.init(WindowDecorActionBar.java:199)
at com.android.internal.app.WindowDecorActionBar.<init>(WindowDecorActionBar.java:181)
at android.app.Dialog.show(Dialog.java:477)
at androidx.fragment.app.DialogFragment.onStart(DialogFragment.java:993)
at androidx.fragment.app.Fragment.performStart(Fragment.java:3187)
at androidx.fragment.app.FragmentStateManager.start(FragmentStateManager.java:628)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:290)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1943)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1845)
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1782)
at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:565)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8810)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
The text was updated successfully, but these errors were encountered:
vikash-sh
changed the title
I am getting NullPointerException in my Activity as soon as I call the show method.
I am getting NullPointerException in my Activity as soon as I call the dpd.show() method.
May 20, 2024
@wdullaer
My MainActivity class extends a BaseFragmentActivity (Custom) which extends FragmentActivity and I can't change it as changing it disturbs my App's functionality. MainActivity neither includes a ToolBar nor it's hidden in styles.xml for the Custom MainActivity Theme. Now I implemented the library as
implementation 'com.wdullaer:materialdatetimepicker:4.2.3'
and used the sample code to show DatePickerDialog as below but I am getting an exception which occurs as soon as I click onimageSearch ImageView
. Please help me to resolve this issue. Also, I am implementing it in Tablet UI.build.gradle (:app)
Code:
Crash:
The text was updated successfully, but these errors were encountered: