skip to Main Content

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

3

Answers


  1. change the init button to

    val button=findViewById<Button>(R.id.login_btn)
    
    Login or Signup to reply.
  2. in my case i have removed onclick from xml.

    val button : Button = findViewById(R.id.login_btn);
        button.setOnClickListener { 
            
        }
    
    Login or Signup to reply.
  3. If no answers above can help you, you can use viewbinding to access your view. I had so many problems while using findViewById as a newbie. Here is the documentation,

    https://developer.android.com/topic/libraries/view-binding

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search