0

I made a fragment name OrderYourFoodFragment and inside of the fragment i place a BottomDialogFragment but issue is I placed a button on the BottomDialogFragment and I want when the button is press the condition is execute and the bottomfragment has to be close and fall back to OrderYourFoodFragment how can i achieve that

I write this code in OrderYourFoodFragment

 red.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                DatabaseReference reference = FirebaseDatabase.getInstance().getReference("Users").child(mobile).child("predict");
                reference.addValueEventListener(new ValueEventListener() {
                    @Override
                    public void onDataChange(@NonNull DataSnapshot snapshot) {
                        String order = snapshot.getValue(String.class);
                        int iorder = Integer.parseInt(order);
                        
                        if (iorder == 0){
                            BottomRedFragment bottomRedFragment = new BottomRedFragment();
                            bottomRedFragment.show(getChildFragmentManager(), bottomRedFragment.getTag());
                            
                        } else {
                            Toast.makeText(getActivity(), "You are already Ordered your Food", Toast.LENGTH_SHORT).show();
                        }
                        
                    }

                    @Override
                    public void onCancelled(@NonNull DatabaseError error) {

                    }
                });


            }
        });

  • What exactly in this code doesn't work the way you expect? Tell us what is wrong with shared code. Do you have any errors? – Alex Mamo Sep 08 '21 at 07:11
  • @AlexMamo No It's not give any errors but i want to close BottomDialogFragment from bottomDialog Fragment – gauravmandall Sep 08 '21 at 07:47
  • Is your onDataChange even triggered? – Alex Mamo Sep 08 '21 at 07:51
  • @AlexMamo yes i want to know which command is used to slide down automatically and close bottomDialogFragment I watched this (https://www.youtube.com/watch?v=bXzNIUKYHF0) video to make this bottom sheet but i want to close automatically if someone clicks on the button. This video helps what i want to say if I'm not able to explain the issue – gauravmandall Sep 08 '21 at 10:02

1 Answers1

0

Please see this.

bottomSheetDialogFragment.dismiss();

Reference Link

Aftab Abbas
  • 47
  • 1
  • 10