I saw I lot of videos says that the Kotlin can recognize the buttons (views) automatically in MainActivity.kt I try this but it doesn't work for me in android studio 4.1 when I'm using the usual code with :
var button_name = findViewById(R.id.buttonName)
it works fine but when I'm using the code directly like this :
buttonName.setonclicklistiner{}
the IDE doesn't recognize the button
PS : this the imports in the mainactivity
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
What can i do for access my button or textView automatically in MainActivity.kt