title: Why is "activity" linked to "getActivity()" in Fragment in Kotlin?
body: <p>I'm reading the sunflower code which is offered to show how to use Kotlin in Android development: <a href="https://github.com/android/sunflower/blob/master/app/src/main/java/com/google/samples/apps/sunflower/HomeViewPagerFragment.kt" rel="nofollow noreferrer">https://github.com/android/sunflower/blob/master/app/src/main/java/com/google/samples/apps/sunflower/HomeViewPagerFragment.kt</a></p>
  
  <p>at line 50:</p>
  
  <pre><code>(activity as AppCompatActivity).setSupportActionBar(binding.toolbar)
  </code></pre>
  
  <p>but I can't find where the "activity" be defined. If "ctrl+click" in Android Studio, it jump to "getActivity()" in Fragment.java. If anyone can tell me where it be defined and what's the magic it jump to "getActivity()"?</p>
  
  <p>It seems to be a var in AppCompatActivity or Fragment or any super class, but I don't know how to locate it.</p>