title: DialogFragment is not showing when button is clicked
body: <p>I want a default dialog, meaning i don't want to custom the dialog fragment. I am using the onCreateDialog to do this, but nothing shows up when i click a button associated with it. Am i suppose to create a view to link this dialog to? am i mistaken thinking i can just use a default dialog? For the scenario the main activity has a button and once clicked, i want the RandomDialogFragment to appear, but nothing seems to be working.</p>
  <p><strong>RandomDialog class which extends DialogFragment</strong></p>
  <pre><code>class RandomDialogFragment : DialogFragment() {
  
      companion object{
          const val KEY: String = &quot;KEY&quot;
          lateinit var param: String
  
          fun newInstance(text: String): RandomDialogFragment {
  
              //use a bundle to to add arguments to fragment
              val args = Bundle()
              args.putString(KEY, text)
  
              val randomDialogFrag = RandomDialogFragment()
              randomDialogFrag.arguments = args
              return randomDialogFrag
  
          }
      }
  
  
      override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
  
  
          val builder: AlertDialog.Builder = AlertDialog.Builder(activity)
  
   
          param = arguments?.getString(KEY)!!
  
          builder.setTitle(&quot;Random Joke&quot;)
  
          builder.setMessage(param)
              .setPositiveButton(&quot;Dismiss&quot;, object : DialogInterface.OnClickListener {
                  override fun onClick(p0: DialogInterface?, p1: Int) {
                      dismiss()
                  }
  
              })
              .setNegativeButton(&quot;Ok&quot;, object: DialogInterface.OnClickListener {
                  override fun onClick(p0: DialogInterface?, p1: Int) {
                      dismiss()
                  }
  
              })
  
          return builder.create()
      }
      
  }
  </code></pre>
  <p><strong>main activity</strong></p>
  <pre><code>class MainActivity() : AppCompatActivity() {
  
      lateinit var binding: ActivityMainBinding
      lateinit var randomJokeViewModel: RandomJokeViewModel
  
  
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
  
          binding = ActivityMainBinding.inflate(layoutInflater)
          setContentView(binding.root)
  
          val retrofitService = RetrofitService.getInstance()
  
          val randomJokeRepo = JokeRepo(retrofitService!!)
  
  
          randomJokeViewModel = ViewModelProvider(this, RandomJokeViewModelFactory(randomJokeRepo))
              .get(RandomJokeViewModel::class.java)
  
  
  //Button i want clicked in main activity to show dialog fragment
          binding.randomJokeBtn.setOnClickListener {
  
              Log.d(&quot;random joke btn clicked&quot; , &quot;true&quot;)
  
              configureObservers()
  
               //api call
              randomJokeViewModel.getRandomJoke()
  
          }
  
      }
  
      private fun configureObservers() {
  
          randomJokeViewModel.randomJokeLiveData.observe(this, {
  
                 //passing the string to be the main message of the dialog via retrofit 
              RandomDialogFragment.newInstance(it.value.joke)
                  .show(supportFragmentManager, RandomDialogFragment.KEY)
  
          })
  
      }
  }
  </code></pre>