I was just testing input/output, there was no special purpose, this is the last code that had run successfully:
public class MainActivity extends AppCompatA
Instance member variables are initialized when the instance itself is initialized. It's too early for findViewById()
Before onCreate()
your activity does not yet have a Window
that findViewById()
needs internally. Before setContentView()
(that you should be calling in onCreate()
) there are no views to be found either.
Therefore init your view references in onCreate()
and after setContentView()
.