我有fragment,它包含recycleview和list。在fragment中,我正在调用另一个底层工作表dialog fragment,我想知道当我关闭底层工作表dialog fragment时如何刷新基本片段列表。我在基本片段中尝试了onpause和onresume方法。请帮我解决这个问题。
fragment
recycleview
dialog fragment
onpause
onresume
ukxgm1gy1#
此方法在对话框碎片被消除时触发。重写对话框片段中的方法。
@Override public void onDismiss(@NonNull DialogInterface dialog) { super.onDismiss(dialog); // use interface to callback method in base fragment }
字符串
insrf1ej2#
我不确定,但我试过破解密码,成功了。
@Override public void dismiss() { super.dismiss(); ((MyActivity)context).myRefreshFunction();// }
gupuwyp23#
调用BottomSheetDialogFragment单击事件打开按钮SheetDialgFragment
class GuestFragment : Fragment(){ . . . . override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) binding.tvInfo.setOnClickListener { val dialogFragment = BottomSheetDogGiveReviewFragment(requireContext(),data.ratingData,data) // call back method dialogFragment.setOnBottomSheetDismissListener { resumeFragment() } dialogFragment.show(parentFragmentManager, "My Fragment") } } }
字符串在底部工作表对话框片段中
class BottomSheetDogGiveReviewFragment(context: Context) : BottomSheetDialogFragment() { //this is binding xml file private var _binding : FragmentBottomSheetDogGiveReviewBinding?=null private val binding get() = _binding!! //make this listener through call over Fragment mehod private var onDismissListener: (() -> Unit)? = null fun setOnBottomSheetDismissListener(listener: () -> Unit) { onDismissListener = listener } override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { // Inflate the layout for this fragment _binding = FragmentBottomSheetDogGiveReviewBinding.inflate(inflater, container, false) val view = binding.root return view } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) //button click binding.tvSubmit.setOnClickListener { .... .. dialog!!.dismiss() onDismissListener?.invoke() } } //dialog them override fun getTheme(): Int { return R.style.CustomBottomSheetDialog } }
型// buttom sheet dialog them //在themes.xml文件中添加主题
//buttom sheet dialog style <style name="CustomBottomSheetDialog" parent="@style/ThemeOverlay.MaterialComponents.BottomSheetDialog"> <item name="bottomSheetStyle">@style/CustomBottomSheet</item> </style>
型
3条答案
按热度按时间ukxgm1gy1#
此方法在对话框碎片被消除时触发。重写对话框片段中的方法。
字符串
insrf1ej2#
我不确定,但我试过破解密码,成功了。
字符串
gupuwyp23#
调用BottomSheetDialogFragment
单击事件打开按钮SheetDialgFragment
字符串
在底部工作表对话框片段中
型
// buttom sheet dialog them //在themes.xml文件中添加主题
型