Я пытаюсь так, но это дает мне ошибку
Fragment EditSubCategoryFragment{359a98c #3 id=0x7f090094} declared target fragment EditCategoryFragment{d1e08d5} that does not belong to this FragmentManager!
Код
val newFragment = EditSubCategoryFragment()
val args = Bundle()
args.putString(AppConstants.CAT_ID, category.getId().toString()) //cat_id for which cat has subCategory
newFragment.arguments = args
val transaction = activity?.supportFragmentManager?.beginTransaction()
newFragment.setTargetFragment(EditCategoryFragment(), successAddSubCat)
transaction?.addToBackStack(null)
transaction?.add(R.id.frameContainer, newFragment)?.commit()