My question is if it is possible to write code before setContentView()
in the onCreate()
method of the main Activity
. In the code below I
The setContentView()
method sets the content of your XML file as the View
, which is shown by the Activity
.
You're calling setVariables()
before you've specified any View
to be shown.
That's why the error raises. The compiler doesn't know where that View
belongs to. If you want to use a ResourceView
, you have to set it first.