0

This is my BottomsheetFragment Showing method. When I user new BottomSheetFragment().dismiss(); then shut down apps.

 new BottomSheetFragment().
                            show(requireActivity().getSupportFragmentManager(),
                                    new BottomSheetFragment().getTag());

This code properly shows bottom sheet Dialog. But I can't user dismiss(); What is the solution to these issues? Thanks.

SRINATH
  • 1
  • 8

1 Answers1

0

The problem is that instead of BottomSheetFragment object your are using BottomSheetFragment class to call dismiss. Please have a look on the code below

BottomSheetFragment mBottomSheetFragment = new BottomSheetFragment().
                                show(requireActivity().getSupportFragmentManager(),
                                        new BottomSheetFragment().getTag());
    
    mBottomSheetFragment.dismiss();
MRazaImtiaz
  • 1,964
  • 1
  • 13
  • 23
  • I want to dismiss on adapterClass . When calling new BottomSheetFragment().dismiss(); then stop apps... :( – SRINATH Nov 29 '20 at 09:45
  • you have to use interface so you can call your clickListener of adapter class to the Activity https://stackoverflow.com/questions/49969278/recyclerview-onclicklistener-using-interface/49969478#49969478 as mentioned here – MRazaImtiaz Nov 29 '20 at 09:49