Skip to content
Advertisement

Can’t Access XML form Main Activity in Android Studio [closed]

I cannot access the elements in my XML form the main activity, writing the element id throws errors as if the element is not even there. Basically Main can’t see what is written in XML file, even though they are linked.

Can’t detect the getBmiButton button from XML

Button was defined here

Advertisement

Answer

you Don’t need findViewById() anymore. You should Integrate Kotlin Android Extensions by adding these lines to build.gradle (app)

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

and use your view as a property. If you are curious how this works, this article will help you.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement