Answers for "kotlin binding example"

1

kotlin binding example

//In build.gradle(Module) add this
buildFeatures {
        viewBinding true
    }
    
//In HomePage.kt 
class HomePage : AppCompatActivity()
{
    //This line changes depending on the class name. Also there's an import
    private lateinit var binding: ActivityHomePageBinding

    override fun onCreate(savedInstanceState: Bundle?)
    {
          super.onCreate(savedInstanceState)
          
          
          binding = ActivityHomePageBinding.inflate(layoutInflater)
          setContentView(binding.root)
          
          binding.BTNLoginToAccount.setOnClickListener {
               val nextPage = Intent(this, Login::class.java)
              startActivity(nextPage)
          
          }
    }
}
Posted by: Guest on September-08-2021

Browse Popular Code Answers by Language