Home > Back-end >  Android Studio Kotlin - Onclick listener not being recognized
Android Studio Kotlin - Onclick listener not being recognized

Time:06-16

So this is my first time using Kotlin and Android studio and I really got to say thus far my experience has been horrible. No other language or IDE has put me in the position where I had to do more than hours research to try and make a simple button load the next page and then still being unable to do it.

This is my Login.kt page and there you can see its having problems with the findviewbyID and setonlclicklistener. Top of my Activity_login.xml page The button im trying to create the onclick event for.

Please keep in mind I did try just the normal creation of setonclick for the button but then I didnt seem to recognize that I have a button with the ID of login_btn

CodePudding user response:

change the init button to

val button=findViewById<Button>(R.id.login_btn)

CodePudding user response:

in my case i have removed onclick from xml.

val button : Button = findViewById(R.id.login_btn);
    button.setOnClickListener { 
        
    }
  • Related