【发布时间】:2020-11-20 18:59:42
【问题描述】:
今天我想知道是否有可能做到这一点。我的意思是,当我加载子视图时发送父视图。换句话说,当我在孩子身上时,我想处理父母。
父视图
imgFilter.setOnClickListener {
MyDialogFragment().show(requireActivity().supportFragmentManager,"filter_dialog")
}
子视图
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
}
}
如果有可能,我不知道,或者如果您有其他建议,我会在这里听取和学习。
非常感谢!
【问题讨论】:
-
parentFragment?.view是你需要的吗? -
parentFragment = null :c
-
试试
MyDialogFragment().show(childFragmentManager, "filter_dialog") -
非常感谢你让我度过了愉快的一天
-
是否愿意通过对答案的投票来回馈支持?
标签: kotlin bottom-sheet android-bottomsheetdialog bottomsheetdialogfragment