title: Android Studio - Kotlin: Import Button
body: <p>I know this is probably a quite simple question to answer but I want to import my button from activity_main.xml with the id &quot;button1&quot;:</p>
  <pre><code>&lt;Button
      android:id=&quot;@+id/button1&quot;
      android:layout_width=&quot;wrap_content&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:text=&quot;Button&quot;
      app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
      app:layout_constraintEnd_toEndOf=&quot;parent&quot;
      app:layout_constraintStart_toStartOf=&quot;parent&quot;
      app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  </code></pre>
  <p>In the MainActivity.kt so I can add a setOnClickListener to it.
  I saw something like this:
  MainActivity.kt:</p>
  <pre><code>val button1 = findViewById(R.id.button1) as Button
  </code></pre>
  <p>That gives me 2 errors:
  unresolved reference: findViewById;
  unresolved reference: Button;
  This is the action I want to add:</p>
  <pre><code>button1.setOnClickListener {
              Toast.makeText(applicationContext, &quot;Hello World&quot;, Toast.LENGTH_LONG).show()
          }
  </code></pre>
  <p>So I could use the setOnClickListener on &quot;button1&quot; but it wont work.
  Whats the standard way of importing a button with kotlin so I can use it properly?</p>