diff --git a/catalog/java/io/material/catalog/datepicker/DatePickerMainDemoFragment.java b/catalog/java/io/material/catalog/datepicker/DatePickerMainDemoFragment.java index a7408b212ca..d5262479172 100644 --- a/catalog/java/io/material/catalog/datepicker/DatePickerMainDemoFragment.java +++ b/catalog/java/io/material/catalog/datepicker/DatePickerMainDemoFragment.java @@ -33,6 +33,7 @@ import androidx.annotation.AttrRes; import androidx.annotation.Nullable; import androidx.core.util.Pair; +import androidx.fragment.app.Fragment; import com.google.android.material.button.MaterialButton; import com.google.android.material.datepicker.CalendarConstraints; import com.google.android.material.datepicker.CompositeDateValidator; @@ -163,13 +164,18 @@ public View onCreateDemoView( builder.setCalendarConstraints(constraintsBuilder.build()); MaterialDatePicker picker = builder.build(); addSnackBarListeners(picker); - picker.show(getChildFragmentManager(), picker.toString()); + picker.show(getChildFragmentManager(), "MaterialDatePicker"); } catch (IllegalArgumentException e) { snackbar.setText(e.getMessage()); snackbar.show(); } }); + Fragment fragment = getChildFragmentManager().findFragmentByTag("MaterialDatePicker"); + if (fragment instanceof MaterialDatePicker) { + addSnackBarListeners((MaterialDatePicker) fragment); + } + return view; }