Skip to content Skip to sidebar Skip to footer

How To Dismiss A Dialog Fragment From A Recyclerview Adapter

A silly question but I am new to Android and I’ve spent a few hours looking around but can’t find the answer. I have a dialog fragment with a recyclerview in it. I want the di

Solution 1:

  1. Add to the adapter a constructor that receive DialogFragment and save it as a field.
  2. When you create the Adapter do new EvMySchedAdapter(dayList, EvMySchedDlg.this);

  3. Inside the onClick call dialgFragment.dismiss();

Solution 2:

for Kotlin Users

classSomeAdapter(private val dialog: BottomSheetDialog):RecyclerView.Adapter<SomeAdapter.ViewHolder>()

holder.itemView.setOnClickListener{
dialog.dismiss()
}

Post a Comment for "How To Dismiss A Dialog Fragment From A Recyclerview Adapter"