title: How to make a custom DialogFragment in Android?
body: <p>I am trying to show a custom dialog from a fragment. When it is about to be displayed the screen gets darker, but no dialog is presented. I also tried to show it from the activity containing the fragment, but I get the same result. </p>
  
  <p>Here is the layout for my dialog:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;androidx.constraintlayout.widget.ConstraintLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:layout_width="match_parent"
      android:layout_height="239dp"
      android:background="#00f"
      &gt;
  
      &lt;androidx.constraintlayout.widget.ConstraintLayout
          android:layout_width="match_parent"
          android:layout_height="210dp"
          android:layout_marginStart="20dp"
          android:layout_marginLeft="20dp"
          android:layout_marginEnd="20dp"
          android:layout_marginRight="20dp"
          android:background="@drawable/pop_up_shape"
          android:backgroundTint="#00ff00"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toTopOf="parent"
          &gt;
  
      &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  </code></pre>
  
  <p>This is my dialog fragment class:</p>
  
  <pre><code>class AddPlaylistPopUp: DialogFragment(){
  
      override fun onCreateView(
          inflater: LayoutInflater,
          container: ViewGroup?,
          savedInstanceState: Bundle?
      ): View? {
          return inflater.inflate(R.layout.add_playlist_popup_layout, container, true)
      }
  }
  </code></pre>
  
  <p>and this is the method that should open the dialog in the activity:</p>
  
  <pre><code>   fun testBut(view: View) {
          val fm: FragmentManager = supportFragmentManager
          val editNameDialogFragment = AddPlaylistPopUp()
          editNameDialogFragment.show(fm, "fragment_edit_name")
      }
  </code></pre>
  
  <p>in the fragment I tried like this:</p>
  
  <pre><code>  fun openDialog(){
          val fm = fragmentManager!!
          val editNameDialogFragment = AddPlaylistPopUp()
          editNameDialogFragment.show(fm, "fragment_edit_name")
      }
  </code></pre>
  
  <p>This is the guide I followed:
  <a href="https://guides.codepath.com/android/Using-DialogFragment#passing-data-to-parent-fragment" rel="nofollow noreferrer">https://guides.codepath.com/android/Using-DialogFragment#passing-data-to-parent-fragment</a></p>