today I'm wondering if it's possible to do this. I mean, when I load a child view send the parent view. In another words I want to handle the parent when I'm on the child.
Parent View
imgFilter.setOnClickListener {
MyDialogFragment().show(requireActivity().supportFragmentManager,"filter_dialog")
}
Child View
class MyDialogFragment : BottomSheetDialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val dialog = super.onCreateDialog(savedInstanceState) as BottomSheetDialog
val view = View.inflate(context, R.layout.filter_sheet_layout, null)
val linearLayout = view.findViewById<LinearLayout>(R.id.root)
val params = linearLayout.layoutParams as LinearLayout.LayoutParams
params.height = getScreenHeight()
linearLayout.layoutParams = params
backArrowClick(view)
hideKeyboard()
dialog.setContentView(view)
mBehavior = BottomSheetBehavior.from(view.parent as View)
parentFragment?.view?.findViewById<TextView>(R.id.name_store)?.text = "Hello World"
return dialog
}
}
I don't if it's possible to do or If you have another suggestion I'm here to hear and learn.
Thank you so much!
The problem is the show
method is receiving as an argument the fragment manager from the activity so it can't find the parent fragment
MyDialogFragment().show(childFragmentManager, "filter_dialog")
Should allow to parentFragment?.view?
to be found.