New to Kotlin. I am trying to create a activity with a member variable holding button object, but compiler gives me error when I try to do findViewById I tried two ways for doing this but none works.
Note: I am not using Android extension
New to Kotlin. I am trying to create a activity with a member variable holding button object, but compiler gives me error when I try to do findViewById I tried two ways for doing this but none works.
Note: I am not using Android extension
 
    
    When you declare your property like this:
var btn = null
... its type gets inferred to Nothing?, which makes it so that nothing other than null can ever be assigned to it. What you should do instead is the following:
var btn: Button? = null
You might also want to look into declaring your Views in different ways.
