0

I have a DialogFragment which contains a FragmentContainerView with the following layout:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.fragment.app.FragmentContainerView
    android:id="@+id/fcvFiles"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:layout_marginStart="8dp"
    android:layout_marginTop="32dp"
    android:layout_marginEnd="8dp"
    android:layout_marginBottom="8dp"
    app:layout_constraintBottom_toTopOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

The FragmentContainerView should be replaced with a Fragment. Therefore I have a method insertNestedFragment() which is invoked in onViewCreated of the DialogFragment.

private void insertNestedFragment() {
MyFragment myFragment = MyFragment.newInstance();
getChildFragmentManager().beginTransaction().add(R.id.fcvFiles, myFragment).commit();
}

MyFragment contains a RecyclerView which is filled in the onViewCreated method.

On the basis of debug messages in MyFragment I see that the RecyclerView is filled correctly. The problem is, that the DialogFragment does not show the updated Fragment. Is there a possibillity to refresh the DialogFragment or the FragmentContainerView after the onViewCreated method of MyFragment was executed?

2
  • When you say the DialogFragment does not show the updated list, are you calling notifyDataSetChanged() in the Adapter? Commented Sep 26, 2020 at 7:35
  • Sorry, I meant the updated Fragment (MyFragment). I also include MyFragment in a Activity, which has a FragmentContainerView in its layout where I add MyFragment in the same way. There everything works fine. Commented Sep 26, 2020 at 9:36

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.