title: Why does it still say "Unresolved reference: button" even when I have button id in xml?
body: <p>I have simple android app, and I want to click button to pass other activity. But it says</p>
  <blockquote>
  <p>Unresolved reference: button</p>
  </blockquote>
  <p>even I give id in xml. I do not know where I mistake.</p>
  <p><strong>Screenshot:</strong></p>
  <p><a href="https://i.stack.imgur.com/tRnVR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tRnVR.png" alt="enter image description here" /></a></p>
  <p><strong>activity_main.xml:</strong></p>
  <pre><code>   &lt;Button
      android:layout_width=&quot;wrap_content&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:id=&quot;@+id/button&quot;
      android:text=&quot;Click&quot;
      app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
      app:layout_constraintLeft_toLeftOf=&quot;parent&quot;
      app:layout_constraintRight_toRightOf=&quot;parent&quot;
      app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  </code></pre>
  <p><strong>main_activity:</strong></p>
  <pre><code>class MainActivity : AppCompatActivity() {
  
  companion object {
  const val USER = &quot;user&quot;
   }
  
   override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      setContentView(R.layout.activity_main)
  
      val user = User( &quot;mayk&quot;,   &quot;qqqq&quot;, PersonalInfo(&quot;mayk&quot;, &quot;james&quot;))
  
  
      button.setOnClickListener{
          val intent = Intent (this, Activity2::class.java)
          intent.putExtra(USER, user)
          startActivity(intent)
      }
     }
     }
  </code></pre>