我正在使用带有导航架构组件的BottomSheetDialogFragment类。我遵循单一活动模式,因此只有一个活动和多个片段。以下是我的代码。
BottomSheetDialogFragment.kt
class LogoBottomSheetFragment : BottomSheetDialogFragment() {
private var _binding: FragmentBottomSheetAccountLogoBinding? = null
private val binding get() = _binding!!
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
_binding = FragmentBottomSheetAccountLogoBinding.inflate(inflater, container, false)
return binding.root
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
}
这是我从主片段打开导航.xml中对话框的方法:
<dialog
android:id="@+id/logoBottomSheetFragment"
android:name="com.th3pl4gu3.locky.ui.main.add.account.LogoBottomSheetFragment"
android:label="LogoBottomSheetFragment"
tools:layout="@layout/fragment_bottom_sheet_account_logo" />
现在我想要从底部表单传递数据到主碎片。
有没有合适的方法可以做到这一点?请有人能帮帮我吗。
谢谢。