title: Open fragment from another one in kotlin
body: <p>I'm totally desesperate. I try to open/replace fragment from one to another and only docs I can find is from an Activity or only in Java (with the getFragmentManager() method, seems to not exist in Kotlin).</p>
  
  <p>supportFragmentManager is only available inside an Activity, and I'm using a fragment and adapter.</p>
  
  <p>Could you please help me?</p>
  
  <p>I think it's unless to show my code because it's just give nothing, only errors</p>
  
  <p>None of the answers worked for me.
  I tried something else and create an interface :</p>
  
  <pre><code>interface AdapterCallbackAlbum {
  fun onClickItem(album: Album)}
  </code></pre>
  
  <p>And implement this in my first fragment </p>
  
  <pre><code>class ListAlbumsFragment : Fragment(), AdapterCallbackAlbum {
    override fun onClickItem(album: Album) {
    val fragment = ListTracksFragment.newInstance()
    val transaction = childFragmentManager.beginTransaction()
    transaction.replace(R.id.album_fragment, fragment)
    transaction.commit()
  }
  </code></pre>
  
  <p>And finally the adapter: </p>
  
  <pre><code>    class AlbumAdapter(val context: Context, private val 
      adapterCallbackAlbum: AdapterCallbackAlbum): Adapter&lt;ViewHolder&gt;() {
      override fun onBindViewHolder(holder: RecyclerView.ViewHolder, 
      position: Int) {
          val album = albumList[position]
          holder.itemView.setOnClickListener { 
            adapterCallbackAlbum.onClickItem(album)
         }}
  </code></pre>
  
  <p>But the only result I get is the second fragment put on the first one even if I call a :</p>
  
  <pre><code>transaction.remove(ListAlbumFragment.newInstance())
  </code></pre>
  
  <p>A friend of mine finally solved my problem (maybe it could help someone).</p>
  
  <pre><code> override fun onClickItem(album: Album) {
      val fragment = ListTracksFragment.newInstance()
      val transaction = fragmentManager.beginTransaction()
      transaction.replace(R.id.content, fragment)
      transaction.addToBackStack(null)
      transaction.commit()
  }
  </code></pre>
  
  <p>The trouble was we start from MainActivity, which load a fragment, inside this fragment, we have to load another one on a click event. So the fragment to replace is not the current fragment, but the content of main_activity.xml.</p>
  
  <p>Thank's to all for your quick answers</p>